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; }
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; }
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); }
internal DataTable GetSchemaRowset(Guid schema, object[] restrictions) { DataTable table2; IntPtr ptr; Bid.ScopeEnter(out ptr, "<oledb.OleDbConnectionInternal.GetSchemaRowset|INFO> %d#, schema=%ls, restrictions\n", base.ObjectID, schema); try { if (restrictions == null) { restrictions = new object[0]; } DataTable table = null; using (IDBSchemaRowsetWrapper wrapper = this.IDBSchemaRowset()) { System.Data.Common.UnsafeNativeMethods.IDBSchemaRowset rowset2 = wrapper.Value; if (rowset2 == null) { throw ODB.SchemaRowsetsNotSupported(this.Provider); } System.Data.Common.UnsafeNativeMethods.IRowset ppRowset = null; Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB> %d#\n", base.ObjectID); OleDbHResult result = rowset2.GetRowset(ADP.PtrZero, ref schema, restrictions.Length, restrictions, ref ODB.IID_IRowset, 0, ADP.PtrZero, out ppRowset); Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB|RET> %08X{HRESULT}\n", result); if (result < OleDbHResult.S_OK) { this.ProcessResults(result); } if (ppRowset != null) { using (OleDbDataReader reader = new OleDbDataReader(this.Connection, null, 0, CommandBehavior.Default)) { reader.InitializeIRowset(ppRowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero); reader.BuildMetaInfo(); reader.HasRowsRead(); table = new DataTable { Locale = CultureInfo.InvariantCulture, TableName = OleDbSchemaGuid.GetTextFromValue(schema) }; OleDbDataAdapter.FillDataTable(reader, new DataTable[] { table }); } } return(table); } } finally { Bid.ScopeLeave(ref ptr); } return(table2); }
internal DataTable GetSchemaRowset(Guid schema, object[] restrictions) { IntPtr hscp; Bid.ScopeEnter(out hscp, "<oledb.OleDbConnectionInternal.GetSchemaRowset|INFO> %d#, schema=%ls, restrictions\n", ObjectID, schema); try { if (null == restrictions) // MDAC 62243 { restrictions = new object[0]; } DataTable dataTable = null; using (IDBSchemaRowsetWrapper wrapper = IDBSchemaRowset()) { UnsafeNativeMethods.IDBSchemaRowset dbSchemaRowset = wrapper.Value; if (null == dbSchemaRowset) { throw ODB.SchemaRowsetsNotSupported(Provider); } UnsafeNativeMethods.IRowset rowset = null; OleDbHResult hr; Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB> %d#\n", ObjectID); hr = dbSchemaRowset.GetRowset(ADP.PtrZero, ref schema, restrictions.Length, restrictions, ref ODB.IID_IRowset, 0, ADP.PtrZero, out rowset); Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB|RET> %08X{HRESULT}\n", hr); if (hr < 0) // ignore infomsg { ProcessResults(hr); } if (null != rowset) { using (OleDbDataReader dataReader = new OleDbDataReader(Connection, null, 0, CommandBehavior.Default)) { dataReader.InitializeIRowset(rowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); dataTable = new DataTable(); dataTable.Locale = CultureInfo.InvariantCulture; dataTable.TableName = OleDbSchemaGuid.GetTextFromValue(schema); OleDbDataAdapter.FillDataTable(dataReader, dataTable); } } return(dataTable); } } finally { Bid.ScopeLeave(ref hscp); } }
internal DataTable GetSchemaRowset(Guid schema, object[] restrictions) { if (null == restrictions) { restrictions = Array.Empty <object>(); } DataTable dataTable = null; using (IDBSchemaRowsetWrapper wrapper = IDBSchemaRowset()) { UnsafeNativeMethods.IDBSchemaRowset dbSchemaRowset = wrapper.Value; if (null == dbSchemaRowset) { throw ODB.SchemaRowsetsNotSupported(Provider); } UnsafeNativeMethods.IRowset rowset = null; OleDbHResult hr; hr = dbSchemaRowset.GetRowset(ADP.PtrZero, ref schema, restrictions.Length, restrictions, ref ODB.IID_IRowset, 0, ADP.PtrZero, out rowset); if (hr < 0) { // ignore infomsg ProcessResults(hr); } if (null != rowset) { using (OleDbDataReader dataReader = new OleDbDataReader(Connection, null, 0, CommandBehavior.Default)) { dataReader.InitializeIRowset(rowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); dataTable = new DataTable(); dataTable.Locale = CultureInfo.InvariantCulture; dataTable.TableName = OleDbSchemaGuid.GetTextFromValue(schema); OleDbDataAdapter.FillDataTable(dataReader, dataTable); } } return(dataTable); } }
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); }
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); }
private OleDbDataReader ExecuteReaderInternal(CommandBehavior behavior, string method) { OleDbDataReader dataReader = null; OleDbException nextResultsFailure = null; int state = ODB.InternalStateClosed; try { ValidateConnectionAndTransaction(method); if (0 != (CommandBehavior.SingleRow & behavior)) { // CommandBehavior.SingleRow implies CommandBehavior.SingleResult behavior |= CommandBehavior.SingleResult; } object executeResult; int resultType; switch(CommandType) { case 0: // uninitialized CommandType.Text case CommandType.Text: case CommandType.StoredProcedure: resultType = ExecuteCommand(behavior, out executeResult); break; case CommandType.TableDirect: resultType = ExecuteTableDirect(behavior, out executeResult); break; default: throw ADP.InvalidCommandType(CommandType); } if (_executeQuery) { try { dataReader = new OleDbDataReader(_connection, this, 0, this.commandBehavior); switch(resultType) { case ODB.ExecutedIMultipleResults: dataReader.InitializeIMultipleResults(executeResult); dataReader.NextResult(); break; case ODB.ExecutedIRowset: dataReader.InitializeIRowset(executeResult, ChapterHandle.DB_NULL_HCHAPTER, _recordsAffected); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); break; case ODB.ExecutedIRow: dataReader.InitializeIRow(executeResult, _recordsAffected); dataReader.BuildMetaInfo(); break; case ODB.PrepareICommandText: if (!_isPrepared) { PrepareCommandText(2); } OleDbDataReader.GenerateSchemaTable(dataReader, _icommandText, behavior); break; default: Debug.Assert(false, "ExecuteReaderInternal: unknown result type"); break; } executeResult = null; _hasDataReader = true; _connection.AddWeakReference(dataReader, OleDbReferenceCollection.DataReaderTag); // command stays in the executing state until the connection // has a datareader to track for it being closed state = ODB.InternalStateOpen; // MDAC 72655 } finally { if (ODB.InternalStateOpen != state) { this.canceling = true; if (null != dataReader) { ((IDisposable) dataReader).Dispose(); dataReader = null; } } } Debug.Assert(null != dataReader, "ExecuteReader should never return a null DataReader"); } else { // optimized code path for ExecuteNonQuery to not create a OleDbDataReader object try { if (ODB.ExecutedIMultipleResults == resultType) { UnsafeNativeMethods.IMultipleResults multipleResults = (UnsafeNativeMethods.IMultipleResults) executeResult; // may cause a Connection.ResetState which closes connection nextResultsFailure = OleDbDataReader.NextResults(multipleResults, _connection, this, out _recordsAffected); } } finally { try { if (null != executeResult) { Marshal.ReleaseComObject(executeResult); executeResult = null; } CloseFromDataReader(ParameterBindings); } catch(Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } if (null != nextResultsFailure) { nextResultsFailure = new OleDbException(nextResultsFailure, e); } else { throw; } } } } } finally { // finally clear executing state try { if ((null == dataReader) && (ODB.InternalStateOpen != state)) { // MDAC 67218 ParameterCleanup(); } } catch(Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } if (null != nextResultsFailure) { nextResultsFailure = new OleDbException(nextResultsFailure, e); } else { throw; } } if (null != nextResultsFailure) { throw nextResultsFailure; } } return dataReader; }
private OleDbDataReader GetDataForReader(IntPtr ordinal, RowBinding rowbinding, int valueOffset) { UnsafeNativeMethods.IRowsetInfo rowsetInfo = IRowsetInfo(); UnsafeNativeMethods.IRowset result; OleDbHResult hr; Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB> %d#, ColumnOrdinal=%Id\n", ObjectID, ordinal); hr = rowsetInfo.GetReferencedRowset((IntPtr)ordinal, ref ODB.IID_IRowset, out result); Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB|RET> %08X{HRESULT}\n", hr); ProcessResults(hr); OleDbDataReader reader = null; if (null != result) { // only when the first datareader is closed will the connection close ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(result, rowbinding, valueOffset); reader = new OleDbDataReader(_connection, _command, 1+Depth, _commandBehavior & ~CommandBehavior.CloseConnection); reader.InitializeIRowset(result, chapterHandle, ADP.RecordsUnaffected); reader.BuildMetaInfo(); reader.HasRowsRead(); if (null != _connection) { // connection tracks all readers to prevent cmd from executing // until all readers (including nested) are closed _connection.AddWeakReference(reader, OleDbReferenceCollection.DataReaderTag); } } return reader; }
private OleDbDataReader ExecuteReaderInternal(CommandBehavior behavior, string method) { OleDbDataReader dataReader = null; OleDbException nextResultsFailure = null; int state = ODB.InternalStateClosed; try { ValidateConnectionAndTransaction(method); if (0 != (CommandBehavior.SingleRow & behavior)) { // CommandBehavior.SingleRow implies CommandBehavior.SingleResult behavior |= CommandBehavior.SingleResult; } object executeResult; int resultType; switch (CommandType) { case 0: // uninitialized CommandType.Text case CommandType.Text: case CommandType.StoredProcedure: resultType = ExecuteCommand(behavior, out executeResult); break; case CommandType.TableDirect: resultType = ExecuteTableDirect(behavior, out executeResult); break; default: throw ADP.InvalidCommandType(CommandType); } if (_executeQuery) { try { dataReader = new OleDbDataReader(_connection, this, 0, this.commandBehavior); switch (resultType) { case ODB.ExecutedIMultipleResults: dataReader.InitializeIMultipleResults(executeResult); dataReader.NextResult(); break; case ODB.ExecutedIRowset: dataReader.InitializeIRowset(executeResult, ChapterHandle.DB_NULL_HCHAPTER, _recordsAffected); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); break; case ODB.ExecutedIRow: dataReader.InitializeIRow(executeResult, _recordsAffected); dataReader.BuildMetaInfo(); break; case ODB.PrepareICommandText: if (!_isPrepared) { PrepareCommandText(2); } OleDbDataReader.GenerateSchemaTable(dataReader, _icommandText, behavior); break; default: Debug.Assert(false, "ExecuteReaderInternal: unknown result type"); break; } executeResult = null; _hasDataReader = true; _connection.AddWeakReference(dataReader, OleDbReferenceCollection.DataReaderTag); // command stays in the executing state until the connection // has a datareader to track for it being closed state = ODB.InternalStateOpen; } finally { if (ODB.InternalStateOpen != state) { this.canceling = true; if (null != dataReader) { ((IDisposable)dataReader).Dispose(); dataReader = null; } } } Debug.Assert(null != dataReader, "ExecuteReader should never return a null DataReader"); } else { // optimized code path for ExecuteNonQuery to not create a OleDbDataReader object try { if (ODB.ExecutedIMultipleResults == resultType) { UnsafeNativeMethods.IMultipleResults multipleResults = (UnsafeNativeMethods.IMultipleResults)executeResult; // may cause a Connection.ResetState which closes connection nextResultsFailure = OleDbDataReader.NextResults(multipleResults, _connection, this, out _recordsAffected); } } finally { try { if (null != executeResult) { Marshal.ReleaseComObject(executeResult); executeResult = null; } CloseFromDataReader(ParameterBindings); } catch (Exception e) { // UNDONE - should not be catching all exceptions!!! if (!ADP.IsCatchableExceptionType(e)) { throw; } if (null != nextResultsFailure) { nextResultsFailure = new OleDbException(nextResultsFailure, e); } else { throw; } } } } } finally { // finally clear executing state try { if ((null == dataReader) && (ODB.InternalStateOpen != state)) { ParameterCleanup(); } } catch (Exception e) { // UNDONE - should not be catching all exceptions!!! if (!ADP.IsCatchableExceptionType(e)) { throw; } if (null != nextResultsFailure) { nextResultsFailure = new OleDbException(nextResultsFailure, e); } else { throw; } } if (null != nextResultsFailure) { throw nextResultsFailure; } } return(dataReader); }
private OleDbDataReader GetDataForReader(IntPtr ordinal, RowBinding rowbinding, int valueOffset) { System.Data.Common.UnsafeNativeMethods.IRowset rowset; System.Data.Common.UnsafeNativeMethods.IRowsetInfo info = this.IRowsetInfo(); Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB> %d#, ColumnOrdinal=%Id\n", this.ObjectID, ordinal); OleDbHResult result = info.GetReferencedRowset(ordinal, ref ODB.IID_IRowset, out rowset); Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB|RET> %08X{HRESULT}\n", result); this.ProcessResults(result); OleDbDataReader reader = null; if (rowset != null) { ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(rowset, rowbinding, valueOffset); reader = new OleDbDataReader(this._connection, this._command, 1 + this.Depth, this._commandBehavior & ~CommandBehavior.CloseConnection); reader.InitializeIRowset(rowset, chapterHandle, ADP.RecordsUnaffected); reader.BuildMetaInfo(); reader.HasRowsRead(); if (this._connection != null) { this._connection.AddWeakReference(reader, 2); } } return reader; }
internal DataTable GetSchemaRowset(Guid schema, object[] restrictions) { IntPtr hscp; Bid.ScopeEnter(out hscp, "<oledb.OleDbConnectionInternal.GetSchemaRowset|INFO> %d#, schema=%ls, restrictions\n", ObjectID, schema); try { if (null == restrictions) { // MDAC 62243 restrictions = new object[0]; } DataTable dataTable = null; using(IDBSchemaRowsetWrapper wrapper = IDBSchemaRowset()) { UnsafeNativeMethods.IDBSchemaRowset dbSchemaRowset = wrapper.Value; if (null == dbSchemaRowset) { throw ODB.SchemaRowsetsNotSupported(Provider); } UnsafeNativeMethods.IRowset rowset = null; OleDbHResult hr; Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB> %d#\n", ObjectID); hr = dbSchemaRowset.GetRowset(ADP.PtrZero, ref schema, restrictions.Length, restrictions, ref ODB.IID_IRowset, 0, ADP.PtrZero, out rowset); Bid.Trace("<oledb.IDBSchemaRowset.GetRowset|API|OLEDB|RET> %08X{HRESULT}\n", hr); if (hr < 0) { // ignore infomsg ProcessResults(hr); } if (null != rowset) { using(OleDbDataReader dataReader = new OleDbDataReader(Connection, null, 0, CommandBehavior.Default)) { dataReader.InitializeIRowset(rowset, ChapterHandle.DB_NULL_HCHAPTER, IntPtr.Zero); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); dataTable = new DataTable(); dataTable.Locale = CultureInfo.InvariantCulture; dataTable.TableName = OleDbSchemaGuid.GetTextFromValue(schema); OleDbDataAdapter.FillDataTable(dataReader, dataTable); } } return dataTable; } } finally { Bid.ScopeLeave(ref hscp); } }
private OleDbDataReader ExecuteReaderInternal(CommandBehavior behavior, string method) { OleDbDataReader dataReader = null; OleDbException previous = null; int num2 = 0; try { object obj2; int num; this.ValidateConnectionAndTransaction(method); if ((CommandBehavior.SingleRow & behavior) != CommandBehavior.Default) { behavior |= CommandBehavior.SingleResult; } switch (this.CommandType) { case ((System.Data.CommandType) 0): case System.Data.CommandType.Text: case System.Data.CommandType.StoredProcedure: num = this.ExecuteCommand(behavior, out obj2); break; case System.Data.CommandType.TableDirect: num = this.ExecuteTableDirect(behavior, out obj2); break; default: throw ADP.InvalidCommandType(this.CommandType); } if (this._executeQuery) { try { dataReader = new OleDbDataReader(this._connection, this, 0, this.commandBehavior); switch (num) { case 0: dataReader.InitializeIMultipleResults(obj2); dataReader.NextResult(); break; case 1: dataReader.InitializeIRowset(obj2, ChapterHandle.DB_NULL_HCHAPTER, this._recordsAffected); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); break; case 2: dataReader.InitializeIRow(obj2, this._recordsAffected); dataReader.BuildMetaInfo(); break; case 3: if (!this._isPrepared) { this.PrepareCommandText(2); } OleDbDataReader.GenerateSchemaTable(dataReader, this._icommandText, behavior); break; } obj2 = null; this._hasDataReader = true; this._connection.AddWeakReference(dataReader, 2); num2 = 1; return dataReader; } finally { if (1 != num2) { this.canceling = true; if (dataReader != null) { dataReader.Dispose(); dataReader = null; } } } } try { if (num == 0) { UnsafeNativeMethods.IMultipleResults imultipleResults = (UnsafeNativeMethods.IMultipleResults) obj2; previous = OleDbDataReader.NextResults(imultipleResults, this._connection, this, out this._recordsAffected); } } finally { try { if (obj2 != null) { Marshal.ReleaseComObject(obj2); obj2 = null; } this.CloseFromDataReader(this.ParameterBindings); } catch (Exception exception3) { if (!ADP.IsCatchableExceptionType(exception3)) { throw; } if (previous == null) { throw; } previous = new OleDbException(previous, exception3); } } } finally { try { if ((dataReader == null) && (1 != num2)) { this.ParameterCleanup(); } } catch (Exception exception2) { if (!ADP.IsCatchableExceptionType(exception2)) { throw; } if (previous == null) { throw; } previous = new OleDbException(previous, exception2); } if (previous != null) { throw previous; } } return dataReader; }
private OleDbDataReader ExecuteReaderInternal(CommandBehavior behavior, string method) { OleDbDataReader dataReader = null; OleDbException previous = null; int num2 = 0; try { object obj2; int num; this.ValidateConnectionAndTransaction(method); if ((CommandBehavior.SingleRow & behavior) != CommandBehavior.Default) { behavior |= CommandBehavior.SingleResult; } switch (this.CommandType) { case ((System.Data.CommandType) 0): case System.Data.CommandType.Text: case System.Data.CommandType.StoredProcedure: num = this.ExecuteCommand(behavior, out obj2); break; case System.Data.CommandType.TableDirect: num = this.ExecuteTableDirect(behavior, out obj2); break; default: throw ADP.InvalidCommandType(this.CommandType); } if (this._executeQuery) { try { dataReader = new OleDbDataReader(this._connection, this, 0, this.commandBehavior); switch (num) { case 0: dataReader.InitializeIMultipleResults(obj2); dataReader.NextResult(); break; case 1: dataReader.InitializeIRowset(obj2, ChapterHandle.DB_NULL_HCHAPTER, this._recordsAffected); dataReader.BuildMetaInfo(); dataReader.HasRowsRead(); break; case 2: dataReader.InitializeIRow(obj2, this._recordsAffected); dataReader.BuildMetaInfo(); break; case 3: if (!this._isPrepared) { this.PrepareCommandText(2); } OleDbDataReader.GenerateSchemaTable(dataReader, this._icommandText, behavior); break; } obj2 = null; this._hasDataReader = true; this._connection.AddWeakReference(dataReader, 2); num2 = 1; return(dataReader); } finally { if (1 != num2) { this.canceling = true; if (dataReader != null) { dataReader.Dispose(); dataReader = null; } } } } try { if (num == 0) { UnsafeNativeMethods.IMultipleResults imultipleResults = (UnsafeNativeMethods.IMultipleResults)obj2; previous = OleDbDataReader.NextResults(imultipleResults, this._connection, this, out this._recordsAffected); } } finally { try { if (obj2 != null) { Marshal.ReleaseComObject(obj2); obj2 = null; } this.CloseFromDataReader(this.ParameterBindings); } catch (Exception exception3) { if (!ADP.IsCatchableExceptionType(exception3)) { throw; } if (previous == null) { throw; } previous = new OleDbException(previous, exception3); } } } finally { try { if ((dataReader == null) && (1 != num2)) { this.ParameterCleanup(); } } catch (Exception exception2) { if (!ADP.IsCatchableExceptionType(exception2)) { throw; } if (previous == null) { throw; } previous = new OleDbException(previous, exception2); } if (previous != null) { throw previous; } } return(dataReader); }