Q:

how to compare a text box value with a table (store in sql server)

i am working on a web site. i need to validate a text box value with a Column ( in table A, using sql server) . 
well, the situation is. When user enter in textbox1 = 45 , before user go to textbox2 , textbox1 check in database if 45 is there. If not give error . 
thanks

A:

Dim Conn as new sqlconnection(..add your sql connection string here..)
Dim cmd as new sqlcommand("SELECT COUNT(*) FROM [TableA] WHERE [Column]=@Value",Conn)
cmd.parameters.add("@Value",sqldbtype.nvarchar).value = textbox1.text

Conn.open
Dim valueExistsInDB as boolean = cbool(cint(cmd.executescalar())>0)
conn.close

Depending on whether the value exists in the table, valueExistsInDB will return True/False

