Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to query a database and compare value entered in a tex..

 
   Database Forums (Home) -> Visual Basic -> DAO RSS
Next:  call a dataset member?  
Author Message
Rohan Kapoor

External


Since: Feb 27, 2007
Posts: 4



(Msg. 1) Posted: Tue Feb 27, 2007 5:07 pm
Post subject: How to query a database and compare value entered in a text box
Archived from groups: microsoft>public>vb>database>dao (more info?)

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.. 
Back to top
Login to vote
Argusy

External


Since: Sep 19, 2003
Posts: 36



(Msg. 2) Posted: Wed Feb 28, 2007 12:41 pm
Post subject: Re: How to query a database and compare value entered in a text box- [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
query - sorry for english. i m facing problem to connect the sql 7.0 data in vb 6.0 through adodc i have clint machine can u help me to solve this problem. thanks

3 table query - I have 3 tables in an Access 2000 DB. C_List CID Name Award CID Alias CID Date_To I need to return all CID and Name from C_List where CID is NOT in Award and Date_To for that CID in Alias is NULL. I moved Date_To from C_List to Alias...

dao select query problem in mfc C++ - hi, i'm using dao for the first time to connect to a MS Access db. I've been following the MS example for a very basic query. This is the MS example: The following code shows the process of creating a recordset from a querydef: // pdb is a pointer t...

Insert query woes - INSERT into [ALIAS] (CID, PFX, DATE_FROM, DATE_TO, DELETED) VALUES ("AA", "BB", #7/25/1942#, #7/25/1942#, true); When I paste this into Query designer, Access gives me all sorts of grief; CID and PFX are required, no default. DATE_...

SQL query match any 10 columns - Hi Is it possible to return a record where a value can match any of 10 columns without nine OR's? /Henning -- Time is present only to prevent everything from happening at once. Still it seems that everything happens at once. Then there must be a bug...
   Database Forums (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]