See other newsgroups
Argusy
Rohan Kapoor wrote:
> Hi,
>
> I am trying to validate the value entered in a text box with the value in
> the database using ado.net by the click of the Check button. For eg: If
> someone enters a domain name in the text box and they click the Check button,
> I want to validate that value with the value in the domainname column of the
> Domain table. If that value matches the domainname in the table, then a label
> will be displayed saying "Domain name already exists" otherwise the Submit
> button will be enabled with a message saying "Correct Domain name". For some
> reason the below code doesn't validate/query the table.
>
> Here is the code:
>
> Protected Sub Check_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Check.Click
> Dim c As String
> Dim a As String
> Dim rs1 As ADODB.Recordset
> Dim abc As ADODB.Connection = New ADODB.Connection()
> abc.ConnectionString = "Provider=SQLOLEDB;Data Source=*****;Initial
> Catalog=******;Persist Security Info=True;User ID=******;Password=******;"
> abc.Open()
> c = "select domainname from Domain"
> rs1 = abc.Execute(c)
> a = Domain.Text
> If Domain.Text = "" Then
> Validate.Visible = True
> Validate.Text = "Please enter a Domain name"
> End If
> If rs1.DataMember = a Then
> Validate.Visible = True
> Validate.Text = "Domain name already exists"
> ElseIf rs1.DataMember <> a Then
> Validate.Visible = True
> Validate.Text = "Correct Domain name"
> Check.Visible = False
> Submit.Visible = True
> End If
> End Sub
>
> I would really appreciate if you could please help me figure this out.
>
> Regards,
>
> Rohan
>
>> Stay informed about: How to query a database and compare value entered in a tex..