Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. myReader = SelectCommand.ExecuteReader();
  2.  
  3. MySqlConnection conn = new MySqlConnection("secretstring")
  4. MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM userspassword where'" + this.loginuser.Text + "'and password'" + this.passworduser.Text, conn);
  5. MySqlDataReader myReader;
  6. conn.Open();
  7. //myReader = SelectCommand.ExecuteReader();
  8. myReader = SelectCommand.ExecuteReader();
  9.  
  10.  
  11. int count = 0;
  12. while (myReader.Read())
  13. {
  14. count = count + 1;
  15. }
  16. if (count == 1)
  17. {
  18. MessageBox.Show("Correct");
  19. Form2 pannel = new Form2();
  20. pannel.Show();
  21. Hide();
  22.  
  23. }
  24. else if (count > 1)
  25. {
  26. MessageBox.Show("More then 1 user logged in");
  27. }
  28. else
  29. MessageBox.Show("Incorrect password or username");
  30. conn.Close();
  31.  
  32. MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM userspassword where " +
  33. "username = '" + this.loginuser.Text + "' and password = '" +
  34. this.passworduser.Text +"'" , conn);
  35.  
  36. MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM userspassword where " +
  37. "username = @uname and password = @pwd", conn);
  38. SelectCommand.Parameters.AddWithValue("@uname",this.loginuser.Text);
  39. SelectCommand.Parameters.AddWithValue("@pwd",this.passworduser.Text);
  40. myReader = SelectCommand.ExecuteReader();
  41.  
  42. "SELECT * FROM userspassword where'" + this.loginuser.Text
  43. ^^^^^^^ Column name is missing..
  44.  
  45. MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM userspassword where " + "YourColumnName = '" + this.loginuser.Text + "' and password '" + this.passworduser.Text +"'" , conn);
  46.  
  47. MySqlCommand SelectCommand =
  48. new MySqlCommand("SELECT * FROM userspassword where username='"
  49. + this.loginuser.Text + "' and password='"
  50. + this.passworduser.Text +"'", conn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement