コード例 #1
0
        //IMPORTAR DETALLES TRAMITES
        private void ImportarDetallesTramites()
        {
            OpenFileDialog OpenFileDialog = new OpenFileDialog();

            if (OpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", OpenFileDialog.FileName);
                string sqlExcel         = String.Format("select * from [{0}$]", "Hoja1");

                DataSet ExDataSet = new DataSet();
                //
                OleDbConnection  ExConexion    = new OleDbConnection(connectionString);
                OleDbCommand     OleDbCommand  = new OleDbCommand(sqlExcel, ExConexion);
                OleDbDataAdapter ExDataAdapter = new OleDbDataAdapter(OleDbCommand);
                //
                ExDataAdapter.Fill(ExDataSet);

                Entidades.Detalles_Tramite Detalles_tramiteDeExcel = new Entidades.Detalles_Tramite();

                for (int i = 0; i < ExDataSet.Tables[0].Rows.Count; i++)
                {
                    Detalles_tramiteDeExcel.idTramite    = Convert.ToInt32(ExDataSet.Tables[0].Rows[i].Field <Double>(0));
                    Detalles_tramiteDeExcel.FechaDetalle = ExDataSet.Tables[0].Rows[i].Field <DateTime>(1);
                    //  Detalles_tramiteDeExcel.Estado = ExDataSet.Tables[0].Rows[i].Field<String>(2);
                    Detalles_tramiteDeExcel.Descripcion = ExDataSet.Tables[0].Rows[i].Field <String>(3);



                    Datos_DetalleTramiteAdapter.AñadirNuevo(Detalles_tramiteDeExcel);
                }
            }
            ActualizarListado();
        }
コード例 #2
0
        //IMPORTAR DETALLES TRAMITES
        private void ImportarDetallesTramites()
        {
            OpenFileDialog OpenFileDialog = new OpenFileDialog();

            if (OpenFileDialog.ShowDialog() == DialogResult.OK)
            {

                string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", OpenFileDialog.FileName);
                string sqlExcel = String.Format("select * from [{0}$]", "Hoja1");

                DataSet ExDataSet = new DataSet();
                //
                OleDbConnection ExConexion = new OleDbConnection(connectionString);
                OleDbCommand OleDbCommand = new OleDbCommand(sqlExcel, ExConexion);
                OleDbDataAdapter ExDataAdapter = new OleDbDataAdapter(OleDbCommand);
                //
                ExDataAdapter.Fill(ExDataSet);

                Entidades.Detalles_Tramite Detalles_tramiteDeExcel = new Entidades.Detalles_Tramite();

                for (int i = 0; i < ExDataSet.Tables[0].Rows.Count; i++)
                {

                    Detalles_tramiteDeExcel.idTramite = Convert.ToInt32(ExDataSet.Tables[0].Rows[i].Field<Double>(0));
                    Detalles_tramiteDeExcel.FechaDetalle = ExDataSet.Tables[0].Rows[i].Field<DateTime>(1);
                  //  Detalles_tramiteDeExcel.Estado = ExDataSet.Tables[0].Rows[i].Field<String>(2);
                    Detalles_tramiteDeExcel.Descripcion= ExDataSet.Tables[0].Rows[i].Field<String>(3);

                    Datos_DetalleTramiteAdapter.AñadirNuevo(Detalles_tramiteDeExcel);
                }

            }
            ActualizarListado();
        }