Esempio n. 1
0
        public static DataTable ConvertOleDbReaderToDataTable(DbDataReader reader)
        {
            int       fieldCount  = reader.FieldCount;
            DataTable schemaTable = reader.GetSchemaTable();
            DataTable dataTable   = DBConn.BuildAndInitDataTable(schemaTable);

            if (dataTable == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                DataRow dataRow = dataTable.NewRow();
                for (int i = 0; i < fieldCount; i++)
                {
                    dataRow[i] = reader[i];
                }
                dataTable.Rows.Add(dataRow);
            }
            return(dataTable);
        }