Advertisement
zer0231

Untitled

May 11th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. private void Button4_Click(object sender, EventArgs e)
  2. {
  3. 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");
  4. string query = "select * from Adminlogin_Table where username = '" + textBox1.Text.Trim() + "' and password = '" + textBox2.Text.Trim() + "'";
  5. SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
  6. DataTable dtbl = new DataTable();
  7. sda.Fill(dtbl);
  8. if (dtbl.Rows.Count == 1)
  9. {
  10. Form2 objForm2 = new Form2();
  11. this.Hide();
  12. objForm2.Show();
  13. }
  14. else
  15. {
  16. MessageBox.Show("Username or Password is Incorrect", "Alert");
  17. count++;
  18. if (count == 3)
  19. {
  20. MessageBox.Show("Tried more than 3 times the program will terminate", "Alert");
  21. Application.Exit();
  22. }
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement