Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select * FROM usuarios WHERE username = '{0}' AND password = '{1}'
- string conex = Conn.Connexion();
- MySqlConnection con = new MySqlConnection(conex);
- try
- {
- MySqlCommand comando = new MySqlCommand();
- comando.CommandText = string.Format(queryes.Login, txtUsuario.Text, txtPasswrd.Text);
- comando.CommandType = CommandType.Text;
- comando.Connection = con;
- con.Open();
- var reader = comando.ExecuteReader();
- var list = new List<UsuarioEntity>();
- if (reader.HasRows)
- {
- while (reader.Read())
- {
- list.Add(new UsuarioEntity
- {
- User = (string)reader[ColumnasDB.username],
- Nombre = (string)reader[ColumnasDB.nombre],
- Apellido = (string)reader[ColumnasDB.apellido],
- Matricula = (int)reader[ColumnasDB.matricula],
- Perfil = (string)reader[ColumnasDB.perfil],
- Activo = (bool)reader[ColumnasDB.isactive],
- });
- }
- }
- if (reader.ToString() != string.Empty)
- {
- UsuarioEntity user = new UsuarioEntity();
- user.Nombre = txtUsuario.Text;
- user.Perfil = reader.ToString();
- MessageBox.Show("ConexionAbiertaCorrectamente");
- }
- con.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement