当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataReader.ReadRowset方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.ReadRowset方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.ReadRowset方法的具体用法?C# OleDbDataReader.ReadRowset怎么用?C# OleDbDataReader.ReadRowset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbDataReader的用法示例。


在下文中一共展示了OleDbDataReader.ReadRowset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DumpToSchemaTable

        internal void DumpToSchemaTable(UnsafeNativeMethods.IRowset rowset) {
            List<MetaData> metainfo = new List<MetaData>();

            object hiddenColumns = null;
            using (OleDbDataReader dataReader = new OleDbDataReader(_connection, _command, Int32.MinValue, 0)) {
                dataReader.InitializeIRowset(rowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero);
                dataReader.BuildSchemaTableInfo(rowset, true, false);

                hiddenColumns = GetPropertyValue(ODB.DBPROP_HIDDENCOLUMNS); // MDAC 55611, 72106
                if (0 == dataReader.FieldCount) {
                    return;
                }

                Debug.Assert(null == dataReader._fieldNameLookup, "lookup already exists");
                FieldNameLookup lookup = new FieldNameLookup(dataReader, -1);
                dataReader._fieldNameLookup = lookup;

                // This column, together with the DBCOLUMN_GUID and DBCOLUMN_PROPID
                // columns, forms the ID of the column. One or more (but not all) of these columns
                // will be NULL, depending on which elements of the DBID structure the provider uses.
                MetaData columnidname = dataReader.FindMetaData(ODB.DBCOLUMN_IDNAME);
                MetaData columnguid = dataReader.FindMetaData(ODB.DBCOLUMN_GUID);
                MetaData columnpropid = dataReader.FindMetaData(ODB.DBCOLUMN_PROPID);

                MetaData columnname = dataReader.FindMetaData(ODB.DBCOLUMN_NAME);
                MetaData columnordinal = dataReader.FindMetaData(ODB.DBCOLUMN_NUMBER);
                MetaData dbtype = dataReader.FindMetaData(ODB.DBCOLUMN_TYPE);
                MetaData columnsize = dataReader.FindMetaData(ODB.DBCOLUMN_COLUMNSIZE);
                MetaData numericprecision = dataReader.FindMetaData(ODB.DBCOLUMN_PRECISION);
                MetaData numericscale = dataReader.FindMetaData(ODB.DBCOLUMN_SCALE);
                MetaData columnflags = dataReader.FindMetaData(ODB.DBCOLUMN_FLAGS);
                MetaData baseschemaname = dataReader.FindMetaData(ODB.DBCOLUMN_BASESCHEMANAME);
                MetaData basecatalogname = dataReader.FindMetaData(ODB.DBCOLUMN_BASECATALOGNAME);
                MetaData basetablename = dataReader.FindMetaData(ODB.DBCOLUMN_BASETABLENAME);
                MetaData basecolumnname = dataReader.FindMetaData(ODB.DBCOLUMN_BASECOLUMNNAME);
                MetaData isautoincrement = dataReader.FindMetaData(ODB.DBCOLUMN_ISAUTOINCREMENT);
                MetaData isunique = dataReader.FindMetaData(ODB.DBCOLUMN_ISUNIQUE);
                MetaData iskeycolumn = dataReader.FindMetaData(ODB.DBCOLUMN_KEYCOLUMN);

                // @devnote: because we want to use the DBACCESSOR_OPTIMIZED bit,
                // we are required to create the accessor before fetching any rows
                dataReader.CreateAccessors(false);

                ColumnBinding binding;
                while (dataReader.ReadRowset()) {
                    dataReader.GetRowDataFromHandle();

                    MetaData info = new MetaData();

                    binding = columnidname.columnBinding; // MDAC 72627
                    if (!binding.IsValueNull()) {
                        info.idname = (string)binding.Value();
                        info.kind = ODB.DBKIND_NAME;
                    }

                    binding = columnguid.columnBinding;
                    if (!binding.IsValueNull()) {
                        info.guid = binding.Value_GUID();
                        info.kind = ((ODB.DBKIND_NAME == info.kind) ? ODB.DBKIND_GUID_NAME : ODB.DBKIND_GUID);
                    }

                    binding = columnpropid.columnBinding;
                    if (!binding.IsValueNull()) {
                        info.propid = new IntPtr(binding.Value_UI4());
                        info.kind = ((ODB.DBKIND_GUID == info.kind) ? ODB.DBKIND_GUID_PROPID : ODB.DBKIND_PROPID);
                    }

                    binding = columnname.columnBinding;
                    if (!binding.IsValueNull()) {
                        info.columnName = (string)binding.Value();
                    }
                    else {
                        info.columnName = "";
                    }

                    if (4 == ADP.PtrSize) {
                        info.ordinal = (IntPtr)columnordinal.columnBinding.Value_UI4();
                    }
                    else {
                        info.ordinal = (IntPtr)columnordinal.columnBinding.Value_UI8();
                    }
                    short wType = unchecked((short) dbtype.columnBinding.Value_UI2());

                    if (4 == ADP.PtrSize) {
                        info.size = unchecked((int) columnsize.columnBinding.Value_UI4()); // WebData 99298
                    }
                    else {
                        info.size = ADP.IntPtrToInt32((IntPtr)unchecked((long)columnsize.columnBinding.Value_UI8()));
                    }

                    binding = numericprecision.columnBinding;
                    if (!binding.IsValueNull()) {
                        info.precision = (byte)binding.Value_UI2();
                    }

                    binding = numericscale.columnBinding;
                    if (!binding.IsValueNull()) {
                        info.scale = (byte)binding.Value_I2();
                    }

//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:OleDbDataReader.cs

示例2: DumpToSchemaTable

 internal void DumpToSchemaTable(System.Data.Common.UnsafeNativeMethods.IRowset rowset)
 {
     List<System.Data.OleDb.MetaData> list = new List<System.Data.OleDb.MetaData>();
     object propertyValue = null;
     using (OleDbDataReader reader = new OleDbDataReader(this._connection, this._command, -2147483648, CommandBehavior.Default))
     {
         reader.InitializeIRowset(rowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero);
         reader.BuildSchemaTableInfo(rowset, true, false);
         propertyValue = this.GetPropertyValue(0x102);
         if (reader.FieldCount == 0)
         {
             return;
         }
         FieldNameLookup lookup = new FieldNameLookup(reader, -1);
         reader._fieldNameLookup = lookup;
         System.Data.OleDb.MetaData data20 = reader.FindMetaData("DBCOLUMN_IDNAME");
         System.Data.OleDb.MetaData data19 = reader.FindMetaData("DBCOLUMN_GUID");
         System.Data.OleDb.MetaData data18 = reader.FindMetaData("DBCOLUMN_PROPID");
         System.Data.OleDb.MetaData data17 = reader.FindMetaData("DBCOLUMN_NAME");
         System.Data.OleDb.MetaData data12 = reader.FindMetaData("DBCOLUMN_NUMBER");
         System.Data.OleDb.MetaData data16 = reader.FindMetaData("DBCOLUMN_TYPE");
         System.Data.OleDb.MetaData data11 = reader.FindMetaData("DBCOLUMN_COLUMNSIZE");
         System.Data.OleDb.MetaData data15 = reader.FindMetaData("DBCOLUMN_PRECISION");
         System.Data.OleDb.MetaData data14 = reader.FindMetaData("DBCOLUMN_SCALE");
         System.Data.OleDb.MetaData data13 = reader.FindMetaData("DBCOLUMN_FLAGS");
         System.Data.OleDb.MetaData data10 = reader.FindMetaData("DBCOLUMN_BASESCHEMANAME");
         System.Data.OleDb.MetaData data9 = reader.FindMetaData("DBCOLUMN_BASECATALOGNAME");
         System.Data.OleDb.MetaData data8 = reader.FindMetaData("DBCOLUMN_BASETABLENAME");
         System.Data.OleDb.MetaData data7 = reader.FindMetaData("DBCOLUMN_BASECOLUMNNAME");
         System.Data.OleDb.MetaData data6 = reader.FindMetaData("DBCOLUMN_ISAUTOINCREMENT");
         System.Data.OleDb.MetaData data5 = reader.FindMetaData("DBCOLUMN_ISUNIQUE");
         System.Data.OleDb.MetaData data4 = reader.FindMetaData("DBCOLUMN_KEYCOLUMN");
         reader.CreateAccessors(false);
         while (reader.ReadRowset())
         {
             reader.GetRowDataFromHandle();
             System.Data.OleDb.MetaData item = new System.Data.OleDb.MetaData();
             ColumnBinding columnBinding = data20.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.idname = (string) columnBinding.Value();
                 item.kind = 2;
             }
             columnBinding = data19.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.guid = columnBinding.Value_GUID();
                 item.kind = (2 == item.kind) ? 0 : 6;
             }
             columnBinding = data18.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.propid = new IntPtr((long) columnBinding.Value_UI4());
                 item.kind = (6 == item.kind) ? 1 : 5;
             }
             columnBinding = data17.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.columnName = (string) columnBinding.Value();
             }
             else
             {
                 item.columnName = "";
             }
             if (4 == ADP.PtrSize)
             {
                 item.ordinal = (IntPtr) data12.columnBinding.Value_UI4();
             }
             else
             {
                 item.ordinal = (IntPtr) data12.columnBinding.Value_UI8();
             }
             short dbType = (short) data16.columnBinding.Value_UI2();
             if (4 == ADP.PtrSize)
             {
                 item.size = (int) data11.columnBinding.Value_UI4();
             }
             else
             {
                 item.size = ADP.IntPtrToInt32((IntPtr) data11.columnBinding.Value_UI8());
             }
             columnBinding = data15.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.precision = (byte) columnBinding.Value_UI2();
             }
             columnBinding = data14.columnBinding;
             if (!columnBinding.IsValueNull())
             {
                 item.scale = (byte) columnBinding.Value_I2();
             }
             item.flags = (int) data13.columnBinding.Value_UI4();
             bool isLong = IsLong(item.flags);
             bool isFixed = IsFixed(item.flags);
             NativeDBType type = NativeDBType.FromDBType(dbType, isLong, isFixed);
             item.type = type;
             if (data6 != null)
             {
                 columnBinding = data6.columnBinding;
                 if (!columnBinding.IsValueNull())
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:OleDbDataReader.cs


注:本文中的System.Data.OleDb.OleDbDataReader.ReadRowset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。