private int FillFromADODB(Object data, object adodb, string srcTable, bool multipleResults) { Debug.Assert(null != data, "FillFromADODB: null data object"); Debug.Assert(null != adodb, "FillFromADODB: null ADODB"); Debug.Assert(!(adodb is DataTable), "call Fill( (DataTable) value)"); Debug.Assert(!(adodb is DataSet), "call Fill( (DataSet) value)"); /* * IntPtr adodbptr = ADP.PtrZero; * try { // generate a new COM Callable Wrapper around the user object so they can't ReleaseComObject on us. * adodbptr = Marshal.GetIUnknownForObject(adodb); * adodb = System.Runtime.Remoting.Services.EnterpriseServicesHelper.WrapIUnknownWithComObject(adodbptr); * } * finally { * if (ADP.PtrZero != adodbptr) { * Marshal.Release(adodbptr); * } * } */ bool closeRecordset = multipleResults; // MDAC 60332, 66668 Type recordsetType = null; UnsafeNativeMethods.ADORecordConstruction record = null; UnsafeNativeMethods.ADORecordsetConstruction recordset = null; try { #if DEBUG ODB.Trace_Cast("Object", "ADORecordsetConstruction", "get_Rowset"); #endif recordset = (UnsafeNativeMethods.ADORecordsetConstruction)adodb; recordsetType = adodb.GetType(); if (multipleResults) { // The NextRecordset method is not available on a disconnected Recordset object, where ActiveConnection has been set to NULL object activeConnection = recordsetType.InvokeMember("ActiveConnection", BindingFlags.GetProperty, null, adodb, new object[0]); if (null == activeConnection) { multipleResults = false; } } } catch (InvalidCastException e) { ADP.TraceException(e); try { #if DEBUG ODB.Trace_Cast("Object", "ADORecordConstruction", "get_Row"); #endif record = (UnsafeNativeMethods.ADORecordConstruction)adodb; multipleResults = false; // IRow implies CommandBehavior.SingleRow which implies CommandBehavior.SingleResult } catch (InvalidCastException f) { // $Consider: telling use either type of object passed in throw ODB.Fill_NotADODB("adodb", f); } } int results = 0; if (null != recordset) { int resultCount = 0; bool incrementResultCount; // MDAC 59632 object[] value = new object[1]; do { string tmp = null; if (data is DataSet) { tmp = DbDataAdapter.GetSourceTableName(srcTable, resultCount); } results += FillFromRecordset(data, recordset, tmp, out incrementResultCount); if (multipleResults) { value[0] = DBNull.Value; try { adodb = recordsetType.InvokeMember("NextRecordset", BindingFlags.InvokeMethod, null, adodb, value); if (null != adodb) { try { #if DEBUG ODB.Trace_Cast("ADODB", "ADORecordsetConstruction", "get_Rowset"); #endif recordset = (UnsafeNativeMethods.ADORecordsetConstruction)adodb; } catch (Exception e) { ADP.TraceException(e); break; } recordsetType = adodb.GetType(); // MDAC 59253 if (incrementResultCount) { resultCount++; } continue; } } catch (TargetInvocationException e) { // MDAC 59244, 65506 if (e.InnerException is COMException) { FillNextResultError((COMException)e.InnerException, e); closeRecordset = true; // MDAC 60408 } else { throw; } } catch (COMException e) { // used as backup to the TargetInvocationException FillNextResultError(e, e); closeRecordset = true; // MDAC 60408 } } break; } while(null != recordset); if ((null != recordset) && (closeRecordset || (null == adodb))) // MDAC 59746, 60902 { FillClose(recordsetType, recordset); } } else if (null != record) { results = FillFromRecord(data, record, srcTable); if (closeRecordset) // MDAC 66668 { FillClose(adodb.GetType(), record); // MDAC 60848 } } else { throw ODB.Fill_NotADODB("adodb", null); } return(results); }