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 is DataReader Object?

793


Explain ado.net features? Benefits? Drawbacks?

806


Explain the difference in an abstract class and an interface?

712


What is oledb driver?

712


Explain the advantage of ADO.Net?

758


What is the difference between typed and untyped dataset?

714


What is difference between Dataview and Datatable?

753


What are the Features and disadvantages of dataset

791


What are the rules to implement connection pooling?

763


What provider ado.net use by default? Explain the role of data provider in ado.net?

739


What is bubbled event can you please explain?

747


how to create a quiz software using 4 options to answer and how to check with answers in the database and award marks....

4009


What is the namespaces being used to access oracle database?

750


What are all components of ADO.Net data provider?

811


What is the use of data grid?

715