Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Button4_Click(object sender, EventArgs e)
- {
- SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Hp\source\repos\student_04\student_04\Database_1.mdf;Integrated Security=True;Connect Timeout=30");
- string query = "select * from Adminlogin_Table where username = '" + textBox1.Text.Trim() + "' and password = '" + textBox2.Text.Trim() + "'";
- SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
- DataTable dtbl = new DataTable();
- sda.Fill(dtbl);
- if (dtbl.Rows.Count == 1)
- {
- Form2 objForm2 = new Form2();
- this.Hide();
- objForm2.Show();
- }
- else
- {
- MessageBox.Show("Username or Password is Incorrect", "Alert");
- count++;
- if (count == 3)
- {
- MessageBox.Show("Tried more than 3 times the program will terminate", "Alert");
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement