SqlConnection con = new SqlConnection("Data Source=.
\\SQLEXPRESS;Initial
Catalog=reception;Integrated Security=True;Pooling=False");
string reception = "SELECT Firstname, Lastname, password,
Email, Gender FROM reception WHERE (Email = @email) AND (password = @password)";
SqlCommand cmd = new SqlCommand(reception, con);
cmd.Parameters.AddWithValue("@email",txtemail.Text);
cmd.Parameters.AddWithValue("@password",txtpass.Text);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if(dr.HasRows)
{
Class1.uname = txtemail.Text;
this.DialogResult=DialogResult.OK;
MessageBox.Show("Login successfully");
txtemail.Clear();
txtpass.Clear();
}
else
{
MessageBox.Show("Invalid UserId or Password.");
}
con.Close();