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

Explain the difference between ado and ado.net?

498


Is it possible to edit data in Repeater control?

525


What is the return type of executescalar?

489


What is the default Timeout for SqlCommand.CommandTimeout property?

499


Explain the overview of ado.net architecture?

511






What is the meaning of executenonquery?

536


What is a sqldataadapter?

519


What is the difference between linq and ado.net?

505


What is the use of SqlCommand object?

637


What are different layers of ADO.Net?

578


What is sql connection in ado.net?

492


List all the steps in order, to access a database through ado.net?

576


Explain the difference between data reader and data adapter?

503


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

521


What is ado oledb and odbc?

499