Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. private void login_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. string myConnection = "datasource = localhost;port=3306;username=root;password=";
  6. MySqlConnection myConn = new MySqlConnection(myConnection);
  7. MySqlCommand SelectCommand = new MySqlCommand("select username, password from library_sys.tbl_users where username = '" + this.txtusername.Text + "' and password = '" + this.txtpword.Text + "';", myConn);
  8. MySqlDataReader myReader;
  9. myConn.Open();
  10. myReader = SelectCommand.ExecuteReader();
  11. int count = 0;
  12.  
  13. while (myReader.Read())
  14. {
  15. count = count + 1;
  16. }
  17. if (count == 1)
  18. {
  19. MessageBox.Show("Welcome to the LIBRARY MANAGEMENT SYSTEM!");
  20. this.Hide();
  21. Librarian lib = new Librarian();
  22. lib.Show();
  23. }
  24. else
  25. {
  26. MessageBox.Show("Invalid username or password.");
  27. myConn.Close();
  28. }
  29. myConn.Close();
  30. }
  31. catch (Exception ex)
  32. {
  33. MessageBox.Show(ex.Message);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement