示例#1
0
        private void Btn_consultaTransporte_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Txt_consultaPlaca.Text.Trim()) == false)
            {
                Dgv_consultaTransporte.Rows.Clear();
                try
                {
                    string         consultaMostrar = "SELECT * FROM tbl_transporte WHERE Placa LIKE ('%" + Txt_consultaPlaca.Text.Trim() + "%');";
                    OdbcCommand    comm            = new OdbcCommand(consultaMostrar, Conexion.nuevaConexion());
                    OdbcDataReader mostrarDatos    = comm.ExecuteReader();

                    while (mostrarDatos.Read())
                    {
                        Dgv_consultaTransporte.Refresh();
                        Dgv_consultaTransporte.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);
                }
            }
        }
示例#2
0
        private void MostrarConsulta()
        {
            try
            {
                string         consultaMostrar = "SELECT * FROM view_Transporte";
                OdbcCommand    comm            = new OdbcCommand(consultaMostrar, Conexion.nuevaConexion());
                OdbcDataReader mostrarDatos    = comm.ExecuteReader();

                while (mostrarDatos.Read())
                {
                    Dgv_consultaTransporte.Refresh();
                    Dgv_consultaTransporte.Rows.Add(mostrarDatos.GetString(0), mostrarDatos.GetString(1), mostrarDatos.GetString(2),
                                                    mostrarDatos.GetString(3));
                }
                comm.Connection.Close();
                mostrarDatos.Close();
            }
            catch (Exception err)
            {
                Console.Write(err.Message);
            }
        }