Advertisement
buzzonit

login

Oct 4th, 2016
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. https://4.bp.blogspot.com/-xtAyprS21k8/Vub4O3Q1d3I/AAAAAAAAHTI/r0bbJ5rnsSkzVaLbFqSHUZnirLfHrcDAA/s1600/2.png
  2.  
  3.  
  4. String caminhodb = "server=127.0.0.1;DATABASE=aula_ds;UID=root;PASSWORD=1234";
  5. MySqlConnection cn = new MySqlConnection(caminhodb);
  6. MySqlCommand cmd = new MySqlCommand("SELECT * FROM cad_alunos WHERE User =?user and pass =?pass", cn);
  7. cmd.parameters.Add("?user", MySqlDbType.VarChar).Value = textBox1.Text;
  8. cmd.parameters.Add("?pass", MySqlDbType.VarChar).Value = textBox2.Text;
  9. cn.Open();
  10. MySqlDataReader le = null;
  11. le = cmd.ExecuteReader();
  12. if (le.Read())
  13. {
  14. Frm_Principal menu = new Frm_Principal();
  15. menu.ShowDialog();
  16. this.Hide();
  17. }
  18. else
  19. {
  20. Message.show("Usuario ou senha incorretos!!");
  21. }
  22.  
  23. }
  24.  
  25.  
  26.  
  27.  
  28. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  29. {
  30. if (e.KeyChar == 13)
  31. {
  32. textBox2.Focus();
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement