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); }
private void DisposeNativeRowset() { System.Data.Common.UnsafeNativeMethods.IRowset o = this._irowset; this._irowset = null; ChapterHandle handle = this._chapterHandle; this._chapterHandle = ChapterHandle.DB_NULL_HCHAPTER; if (ChapterHandle.DB_NULL_HCHAPTER != handle) { handle.Dispose(); } if (o != null) { Marshal.ReleaseComObject(o); } }
public override bool NextResult() { bool flag2; IntPtr ptr2; Bid.ScopeEnter(out ptr2, "<oledb.OleDbDataReader.NextResult|API> %d#\n", this.ObjectID); try { bool flag = false; if (this.IsClosed) { throw ADP.DataReaderClosed("NextResult"); } this._fieldNameLookup = null; OleDbCommand command = this._command; UnsafeNativeMethods.IMultipleResults results = this._imultipleResults; if (results != null) { this.DisposeOpenResults(); this._hasRows = false; do { IntPtr ptr; object ppRowset = null; if ((command != null) && command.canceling) { this.Close(); goto Label_0116; } Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID); OleDbHResult result = results.GetResult(ADP.PtrZero, ODB.DBRESULTFLAG_DEFAULT, ref ODB.IID_IRowset, out ptr, out ppRowset); Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB|RET> %08X{HRESULT}, RecordAffected=%Id\n", result, ptr); if ((OleDbHResult.S_OK <= result) && (ppRowset != null)) { Bid.Trace("<oledb.IUnknown.QueryInterface|API|OLEDB|RowSet> %d#, IRowset\n", this.ObjectID); this._irowset = (System.Data.Common.UnsafeNativeMethods.IRowset) ppRowset; } this._recordsAffected = AddRecordsAffected(this._recordsAffected, ptr); if (OleDbHResult.DB_S_NORESULT == result) { this.DisposeNativeMultipleResults(); goto Label_0116; } this.ProcessResults(result); } while (this._irowset == null); this.BuildMetaInfo(); this.HasRowsRead(); flag = true; } else { this.DisposeOpenResults(); this._hasRows = false; } Label_0116: flag2 = flag; } finally { Bid.ScopeLeave(ref ptr2); } return flag2; }
internal void InitializeIRowset(object result, ChapterHandle chapterHandle, IntPtr recordsAffected) { if ((this._connection == null) || (ChapterHandle.DB_NULL_HCHAPTER != chapterHandle)) { this._rowHandleFetchCount = new IntPtr(1); } this.Initialize(); this._recordsAffected = recordsAffected; this._irowset = (System.Data.Common.UnsafeNativeMethods.IRowset) result; this._chapterHandle = chapterHandle; }