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

How to load multiple tables into a dataset?

782


What are the data access namespaces in .NET?

938


What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

807


Why edit is not possible in repeater?

738


How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?

807


Explain the dataadapter class in ado.net?

908


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

785


How to store data in memory?

733


Define Execute Reader?

865


What is sql connection in ado.net?

737


What are the objects of ado.net?

803


What are the advantage of ado.net?

778


What is openrowset?

745


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

854


Give few examples of datareader that is used in different dataproviders.

777