Guest User

Untitled

a guest
Sep 11th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. private void btnLogin_Click(object sender, EventArgs e)
  2. {
  3. int count = 0;
  4. Connection connection = new Connection();
  5. string sql = "SELECT * FROM tbl_Account WHERE Username='" + txtUserName.Text + "' and Password='" + txtPassword.Text + "'";
  6. MySqlConnection conn = new MySqlConnection(connection.ConnectionString);
  7. MySqlCommand cmd = new MySqlCommand(sql, conn);
  8. conn.Open();
  9. MySqlDataReader dr = cmd.ExecuteReader();
  10.  
  11. while (dr.Read())
  12. {
  13. count++;
  14. }
  15. if (count == 1)
  16. {
  17. MessageBox.Show("Login Successfully!");
  18. this.Hide();
  19. main.showMeForm4(this);
  20. }
  21. else
  22. {
  23. txtPassword.Focus();
  24. MessageBox.Show("Username or Password Is Incorrect");
  25. txtUserName.Text = "";
  26. txtPassword.Text = "";
  27.  
  28. }
  29. conn.Close();
  30. }
Add Comment
Please, Sign In to add comment