Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 string myConnection = "datasource=localhost;port=3306;username=root;password=easteagle";
  6.                 MySqlConnection myConn = new MySqlConnection(myConnection);
  7.                 myConn.Open();
  8.                 MySqlCommand SelectCommand = new MySqlCommand("select ussername,password from `database`.employeeinfo where ussername ='" + this.username_txt.Text+ "' and password ='" + this.password_txt.Text + "' ;" ,myConn);
  9.                
  10.                 MySqlDataReader myReader = SelectCommand.ExecuteReader();
  11.                
  12.                 int count = 0;
  13.  
  14.                 while (myReader.Read())
  15.                 {
  16.                     count++;
  17.                 }
  18.                 if (count == 1)
  19.                 {
  20.                     MessageBox.Show("is good");
  21.                 }
  22.                 else if (count >1)
  23.                 {
  24.                     MessageBox.Show("duplicate password");
  25.                 }
  26.                 else
  27.                 {
  28.                     MessageBox.Show("not good");
  29.                 }
  30.                
  31.  
  32.                 myConn.Close();
  33.             }
  34.             catch (Exception ex)
  35.             {
  36.                 MessageBox.Show(ex.Message);
  37.             }
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement