Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. Select * FROM usuarios WHERE username = '{0}' AND password = '{1}'
  2.  
  3. string conex = Conn.Connexion();
  4. MySqlConnection con = new MySqlConnection(conex);
  5. try
  6. {
  7. MySqlCommand comando = new MySqlCommand();
  8. comando.CommandText = string.Format(queryes.Login, txtUsuario.Text, txtPasswrd.Text);
  9. comando.CommandType = CommandType.Text;
  10. comando.Connection = con;
  11. con.Open();
  12. var reader = comando.ExecuteReader();
  13. var list = new List<UsuarioEntity>();
  14. if (reader.HasRows)
  15. {
  16. while (reader.Read())
  17. {
  18.  
  19. list.Add(new UsuarioEntity
  20. {
  21. User = (string)reader[ColumnasDB.username],
  22. Nombre = (string)reader[ColumnasDB.nombre],
  23. Apellido = (string)reader[ColumnasDB.apellido],
  24. Matricula = (int)reader[ColumnasDB.matricula],
  25. Perfil = (string)reader[ColumnasDB.perfil],
  26. Activo = (bool)reader[ColumnasDB.isactive],
  27. });
  28. }
  29. }
  30.  
  31. if (reader.ToString() != string.Empty)
  32. {
  33. UsuarioEntity user = new UsuarioEntity();
  34. user.Nombre = txtUsuario.Text;
  35. user.Perfil = reader.ToString();
  36.  
  37. MessageBox.Show("ConexionAbiertaCorrectamente");
  38. }
  39.  
  40. con.Close();
  41. }
  42. catch (Exception ex)
  43. {
  44. MessageBox.Show(ex.ToString());
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement