Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / February 2007



Tip: Looking for answers? Try searching our database.

How to query a database and compare value entered in a text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rohan Kapoor - 27 Feb 2007 22:58 GMT
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
Argusy - 28 Feb 2007 02:10 GMT
MULTIPOSTED!!!
Rohan, try cross-posting. The means all replies are seen in all newsgroups.
You will get nasty replies from some in the classic VB newsgroups.

Argusy

> Hi,
>
[quoted text clipped - 41 lines]
>
> Rohan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.