コード例 #1
0
ファイル: OleDbEnumerator.cs プロジェクト: z77ma/runtime
        private static OleDbDataReader GetEnumeratorReader(object?value)
        {
            NativeMethods.ISourcesRowset?srcrowset;

            try
            {
                srcrowset = (NativeMethods.ISourcesRowset?)value;
            }
            catch (InvalidCastException)
            {
                throw ODB.ISourcesRowsetNotSupported();
            }
            if (null == srcrowset)
            {
                throw ODB.ISourcesRowsetNotSupported();
            }

            int          propCount = 0;
            IntPtr       propSets  = ADP.PtrZero;
            OleDbHResult hr        = srcrowset.GetSourcesRowset(ADP.PtrZero, ODB.IID_IRowset, propCount, propSets, out value);

            Exception?f = OleDbConnection.ProcessResults(hr, null, null);

            if (null != f)
            {
                throw f;
            }

            OleDbDataReader dataReader = new OleDbDataReader(null, null, 0, CommandBehavior.Default);

            dataReader.InitializeIRowset(value, ChapterHandle.DB_NULL_HCHAPTER, ADP.RecordsUnaffected);
            dataReader.BuildMetaInfo();
            dataReader.HasRowsRead();
            return(dataReader);
        }
コード例 #2
0
        static private OleDbDataReader GetEnumeratorReader(object value)
        {
            NativeMethods.ISourcesRowset srcrowset = null;

            try {
                srcrowset = (NativeMethods.ISourcesRowset)value;
            }
            catch (InvalidCastException) {
                throw ODB.ISourcesRowsetNotSupported();
            }
            if (null == srcrowset)
            {
                throw ODB.ISourcesRowsetNotSupported();
            }
            value = null; // still held by ISourcesRowset, reused for IRowset

            int    propCount = 0;
            IntPtr propSets  = ADP.PtrZero;

            Bid.Trace("<oledb.ISourcesRowset.GetSourcesRowset|API|OLEDB> IID_IRowset\n");
            OleDbHResult hr = srcrowset.GetSourcesRowset(ADP.PtrZero, ODB.IID_IRowset, propCount, propSets, out value);

            Bid.Trace("<oledb.ISourcesRowset.GetSourcesRowset|API|OLEDB|RET> %08X{HRESULT}\n", hr);

            Exception f = OleDbConnection.ProcessResults(hr, null, null);

            if (null != f)
            {
                throw f;
            }

            OleDbDataReader dataReader = new OleDbDataReader(null, null, 0, CommandBehavior.Default);

            dataReader.InitializeIRowset(value, ChapterHandle.DB_NULL_HCHAPTER, ADP.RecordsUnaffected);
            dataReader.BuildMetaInfo();
            dataReader.HasRowsRead();
            return(dataReader);
        }
コード例 #3
0
        private static OleDbDataReader GetEnumeratorReader(object value)
        {
            System.Data.Common.NativeMethods.ISourcesRowset rowset = null;
            try
            {
                rowset = (System.Data.Common.NativeMethods.ISourcesRowset)value;
            }
            catch (InvalidCastException)
            {
                throw ODB.ISourcesRowsetNotSupported();
            }
            if (rowset == null)
            {
                throw ODB.ISourcesRowsetNotSupported();
            }
            value = null;
            int    cPropertySets = 0;
            IntPtr ptrZero       = ADP.PtrZero;

            Bid.Trace("<oledb.ISourcesRowset.GetSourcesRowset|API|OLEDB> IID_IRowset\n");
            OleDbHResult result = rowset.GetSourcesRowset(ADP.PtrZero, ODB.IID_IRowset, cPropertySets, ptrZero, out value);

            Bid.Trace("<oledb.ISourcesRowset.GetSourcesRowset|API|OLEDB|RET> %08X{HRESULT}\n", result);
            Exception exception = OleDbConnection.ProcessResults(result, null, null);

            if (exception != null)
            {
                throw exception;
            }
            OleDbDataReader reader = new OleDbDataReader(null, null, 0, CommandBehavior.Default);

            reader.InitializeIRowset(value, ChapterHandle.DB_NULL_HCHAPTER, ADP.RecordsUnaffected);
            reader.BuildMetaInfo();
            reader.HasRowsRead();
            return(reader);
        }