i have two textboxes one for user name and another for
password . i have a table name compare(which contains
name,passwod etc.,)my doubt is how compare username
textbox with name column and how compare password textbox
with passwod column. i want the code

Answer Posted / deepak,the infotech icon

sqlConnection con=new sqlConnection();
con.Connectionstring="Data source=servername;Initial
Catalog=databasename;Integrated Security=sspi";
con.open();
string query="SELECT * FROM tablename where name=@name AND
password=@password";
sqlCommand cmd=new sqlCommand(query,con);
cmd.parameters.add(new sqlparameters(@name,textbox1.text));
cmd.parameters.add(new sqlparameters(@password,textbox2.text));
sqlDataReader dr=cmd.Executereader();
while(dr.read())
{
if((textbox1.text==dr[0])&&(textbox2.text==dr[1]))
{
Messagebox.show("YOU ARE SUCCESSFULLY LOGED IN");
return;
}
}
Messagebox.show("INVALID USERNAME OR PASSWORD");

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does datareader object do?

541


How can you add or remove rows from the datatable object of dataset?

581


Which is better entity framework or ado.net?

509


How to add a javaScript function in a datagrid?

571


Which ado.net object is very fast in getting data from the database?

652






Explain the basic use of "dataview" and explain its methods.

532


What is ado.net connection?

468


Explain the advantage of ADO.Net?

556


What is the difference between ado.net and oledb?

483


what is the difference betwen typed dataset and untyped dataset?in general which dataset can we use in programming?

538


Explain the difference in an abstract class and an interface?

506


I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?

553


What is the difference between Response.Expires and Reponse.ExpiresAbsolute?

542


What is the difference between the clone() and copy() methods of the dataset class?

548


What is dataset object? Explain the various objects in dataset.

594