ASP.net:need to get an input from the textbox to be compared to the values in the...

kafu

New member
...dbase and prnt mess. ac? How can I do that. I mean if the values in the textbox corresponds to the database then database values should be shown, else an error message should be shown. How can I do this.
I tried validation but guess cant do that with that.
 
If you are trying to compare the value in a text box with a field in a database then you need to query the database with (im guessing) the string in the text box.

you will need to use the System.Data.SqlClient name space for an SQL database and the code will look a bit like

sqlConnection dbCon = new sqlConnection (SQLCONNECTION STRING);
dbcon.open();
sqlCommand query = new sqlCommand("select * from table where field a = '" + textbox.text + "', dbCon);
SqlDataReader results = query.executereader();

try
{
while(results.read())
{
Enter code to display results
}
}
catch
{
display error
}
finally
{
dbcon.close();
}

If you are using a different type of database then you may need to use different classes but the above code is the general way of doing this wirth an SQL db
 
Back
Top