private void Button1_Click(object sender, EventArgs e) { SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from library_person where username = '******' and password = '******'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); count = Convert.ToInt32(dt.Rows.Count.ToString()); if (count == 0) { MessageBox.Show("Username or password does not match"); } else { this.Hide(); mdi_user mu = new mdi_user(); mu.Show(); } }
private void button1_Click(object sender, EventArgs e) { SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = ("Select *from [dbo].[User] Where UserName='******' and Password='******' "); cmd.ExecuteNonQuery(); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); count = Convert.ToInt32(dt.Rows.Count.ToString()); if (count == 0) { MessageBox.Show("User Name and Password are not match "); } else { this.Hide(); mdi_user mu = new mdi_user(); mu.Show(); } }