Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLogin_Click(object sender, EventArgs e)
- {
- int count = 0;
- Connection connection = new Connection();
- string sql = "SELECT * FROM tbl_Account WHERE Username='" + txtUserName.Text + "' and Password='" + txtPassword.Text + "'";
- MySqlConnection conn = new MySqlConnection(connection.ConnectionString);
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- conn.Open();
- MySqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- count++;
- }
- if (count == 1)
- {
- MessageBox.Show("Login Successfully!");
- this.Hide();
- main.showMeForm4(this);
- }
- else
- {
- txtPassword.Focus();
- MessageBox.Show("Username or Password Is Incorrect");
- txtUserName.Text = "";
- txtPassword.Text = "";
- }
- conn.Close();
- }
Add Comment
Please, Sign In to add comment