SqlConnection con = new SqlConnection(@"Data Source=.\Aroona;Initial Catalog=ACSDatabase;Integrated Security=True;Pooling=False");
SqlDataAdapter loginadp = new SqlDataAdapter("SELECT count(*) FROM Login WHERE username = '" + uName.Text + "' AND password = '" + pWord.Text + "' ", con);
DataTable dt = new DataTable();
loginadp.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
if (uName.Text == "Admin")
{
MPageAdmin mpa = new MPageAdmin();
mpa.Show();
this.Hide();
}
else
{
Main_Page mp = new Main_Page(this.UserName);
mp.Show();
this.Hide();
}
}
else
{
label4.Visible = true;
label4.Text = "Username or Password Incorrect!";
}
This works for me.