public void Ejecutar(string consultar) { ConectarBD.Conectar(); cmd = new MySqlCommand(consultar, ConectarBD.Conectar()); cmd.ExecuteNonQuery(); ConectarBD.Desconectar(); }
//Metodo para ejecutar consulta, recibe un string dependiendo de la consulta public void Ejecutar(string consultar, string mensj) { try { ConectarBD.Conectar(); cmd = new MySqlCommand(consultar, ConectarBD.Conectar()); cmd.ExecuteNonQuery(); MessageBox.Show(mensj); ConectarBD.Desconectar(); } catch (MySqlException myEx) { MessageBox.Show(myEx.Message); } }
public static void llenarCombo(string rol, ComboBox co) { obtenerTabla = "SELECT * FROM registro where rol ='n'"; ConectarBD.Conectar(); MySqlCommand cmd = new MySqlCommand(obtenerTabla, ConectarBD.Conectar()); MySqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { co.Items.Add(r["dni"].ToString() + " " + r["nombre"] + " " + r["apellido"] + " " + r["cedula"]); } ConectarBD.Desconectar(); }