private void btnCancel_Click(object sender, EventArgs e) { con.Open(); cmd = new SqlCommand("SELECT * FROM UserTable WHERE UserName= '******' and Password = '******'", con); da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i == 1) { Main_Form fT = new Main_Form(); fT.Show(); this.Hide(); } else { MessageBox.Show("Not a Registered ADMIN, OR Invalid Username or Password"); } con.Close(); }