Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void login_Click(object sender, EventArgs e)
- {
- try
- {
- string myConnection = "datasource = localhost;port=3306;username=root;password=";
- MySqlConnection myConn = new MySqlConnection(myConnection);
- MySqlCommand SelectCommand = new MySqlCommand("select username, password from library_sys.tbl_users where username = '" + this.txtusername.Text + "' and password = '" + this.txtpword.Text + "';", myConn);
- MySqlDataReader myReader;
- myConn.Open();
- myReader = SelectCommand.ExecuteReader();
- int count = 0;
- while (myReader.Read())
- {
- count = count + 1;
- }
- if (count == 1)
- {
- MessageBox.Show("Welcome to the LIBRARY MANAGEMENT SYSTEM!");
- this.Hide();
- Librarian lib = new Librarian();
- lib.Show();
- }
- else
- {
- MessageBox.Show("Invalid username or password.");
- myConn.Close();
- }
- myConn.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement