For that better to use like this:
protected void Button1_Click1(object
sender, EventArgs e)
{
OleDbConnection
MyConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:\\db2.mdb");
try
{
MyConnection.Open();
string
str = "SELECT count(*) FROM Table1 WHERE name='" +
textBox1.Text + "' AND bday='" +
textBox2.Text + "'";
OleDbCommand
cmd = new OleDbCommand(str,
MyConnection);
int rd = cmd.ExecuteNonQuery();
if (rd == 1 )
{
MyConnection.Close();
Form2 form2 = new Form2();
form2.Show();
this.Hide();
}
else
{
MessageBox.Show("User Name or Password is incorrect");
MyConnection.Close();
}
}
catch
{
MyConnection.Close();
}
}
It will count the matched records and then if it is 1 means then it will
execute another code.
Hope you understand it…