Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- string MyConnection = "datasource=localhost;port=3306;username=root;password=password";
- MySqlConnection MyConn = new MySqlConnection(MyConnection);
- MySqlCommand MyCommand = new MySqlCommand("select * from bans.toollogin where user_name='" + this.UserTextBox.Text + "' and password='" + this.PassTextBox.Text + "' ;", MyConn);
- MySqlDataReader MyReader;
- MyConn.Open();
- MyReader = MyCommand.ExecuteReader();
- int count = 0;
- while (MyReader.Read())
- {
- Console.WriteLine(MyReader[count]);
- count++;
- }
- if (count == 1)
- {
- MessageBox.Show("Username and password is correct");
- this.Hide();
- Form2 f2 = new Form2();
- f2.ShowDialog();
- }
- else if (count > 1)
- {
- MessageBox.Show("Duplicate Username and passwor.\nAccess denied.");
- }
- else
- {
- MessageBox.Show("Username and password is incorrect.\nPleas try again.");
- }
- MyConn.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement