private void button3_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Txt_consultaPago.Text.Trim()) == false) { Dgv_consultaPago.Rows.Clear(); try { string consultaMostrar = "SELECT * FROM tbl_tipopagos WHERE nombreTipoPago LIKE ('%" + Txt_consultaPago.Text.Trim() + "%')" + "AND estadoTipoPago=1" + ";"; OdbcCommand comm = new OdbcCommand(consultaMostrar, Conexion.nuevaConexion()); OdbcDataReader mostrarDatos = comm.ExecuteReader(); while (mostrarDatos.Read()) { Dgv_consultaPago.Refresh(); Dgv_consultaPago.Rows.Add(mostrarDatos.GetString(0), mostrarDatos.GetString(1), mostrarDatos.GetString(2), mostrarDatos.GetString(3)); } comm.Connection.Close(); mostrarDatos.Close(); } catch (Exception err) { Console.WriteLine("ERROR:" + err.Message); } } }
private void MostrarConsulta() { try { string consultaMostrar = "SELECT * FROM tbl_tipopagos WHERE estadoTipoPago = 1;"; OdbcCommand comm = new OdbcCommand(consultaMostrar, Conexion.nuevaConexion()); OdbcDataReader mostrarDatos = comm.ExecuteReader(); while (mostrarDatos.Read()) { Dgv_consultaPago.Refresh(); Dgv_consultaPago.Rows.Add(mostrarDatos.GetInt32(0), mostrarDatos.GetString(1), mostrarDatos.GetString(2), mostrarDatos.GetString(3)); } comm.Connection.Close(); mostrarDatos.Close(); } catch (Exception err) { Console.Write(err.Message); } }