Ejemplo n.º 1
0
 public static void LlenaGrid(DataGridView objetoGrid, string cadenaSQL, params DataParameter[] parametros)
 {
     System.Data.DataTable dt = new System.Data.DataTable();
     try
     {
         using (ispDB db = new ispDB())
         {
             DataReader lector = db.ExecuteReader(cadenaSQL, parametros);
             dt.Load(lector.Reader);
             objetoGrid.DataSource = dt;
         }
     }
     catch (Exception ex)
     {
         General.Mensaje(ex.Message);
     }
 }
Ejemplo n.º 2
0
        //public void LlenaGrid(string tabla, string valorWhere, string campos, string ordenar, List<CamposTabla> parametros, DataGridView objetoGrid)
        //{
        //    System.Data.DataTable dt = new System.Data.DataTable();
        //    try
        //    {
        //        LectorDatos.Instancia.Conexion = this.MkConn();
        //        LectorDatos.Instancia.Abrir("select " + campos + " from " + tabla + " " + valorWhere + " " + ordenar + " limit 100 ", parametros);
        //        dt.Load(LectorDatos.Instancia.Lector);
        //        objetoGrid.DataSource = dt;
        //    }
        //    catch (Exception ex)
        //    {
        //        General.Mensaje(ex.Message);
        //    }
        //    finally
        //    {
        //        LectorDatos.Instancia.Cerrar();
        //    }
        //}

        public static void LlenaGrid(DataGridView objetoGrid, string tabla, string valorWhere, string campos, string ordenar, params DataParameter[] parametros)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            try
            {
                using (ispDB db = new ispDB())
                {
                    DataReader lector = db.ExecuteReader("select " + campos + " from " + tabla + " " + valorWhere + " " + ordenar + " limit 100 ", parametros);
                    dt.Load(lector.Reader);
                    objetoGrid.DataSource = dt;
                }
            }
            catch (Exception ex)
            {
                General.Mensaje(ex.Message);
            }
        }