static internal OleDbException NextResults(UnsafeNativeMethods.IMultipleResults imultipleResults, OleDbConnection connection, OleDbCommand command, out IntPtr recordsAffected) {
            recordsAffected = ADP.RecordsUnaffected;
            List<OleDbException> exceptions = null; // WebData 104564
            if (null != imultipleResults) {
                object result;
                IntPtr affected;
                OleDbHResult hr;


                // MSOLAP provider doesn't move onto the next result when calling GetResult with IID_NULL, but does return S_OK with 0 affected records.
                // we want to break out of that infinite loop for ExecuteNonQuery and the multiple result Close scenarios
                for (int loop = 0;; ++loop) {
                    if ((null != command) && command.canceling) { // MDAC 68964
                        break;
                    }

                    Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB> DBRESULTFLAG_DEFAULT, IID_NULL\n");
                    hr = imultipleResults.GetResult(ADP.PtrZero, ODB.DBRESULTFLAG_DEFAULT, ref ODB.IID_NULL, out affected, out result);
                    Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB|RET> %08X{HRESULT}, RecordAffected=%Id\n", hr, affected);

                    // If a provider doesn't support IID_NULL and returns E_NOINTERFACE we want to break out
                    // of the loop without throwing an exception.  Our behavior will match ADODB in that scenario
                    // where Recordset.Close just releases the interfaces without proccessing remaining results
                    if ((OleDbHResult.DB_S_NORESULT == hr) || (OleDbHResult.E_NOINTERFACE == hr)) { // MDAC 70874
                        break;
                    }
                    if (null != connection) {
                        Exception e = OleDbConnection.ProcessResults(hr, connection, command);
                        if (null != e) {
                            OleDbException excep = (e as OleDbException);
                            if (null != excep) {
                                if (null == exceptions) {
                                    exceptions = new List<OleDbException>();
                                }
                                exceptions.Add(excep);
                            }
                            else {
                                Debug.Assert(OleDbHResult.DB_E_OBJECTOPEN == hr, "unexpected");
                                throw e; // we don't expect to be here, but it could happen
                            }
                        }
                    }
                    else if (hr < 0) {
                        SafeNativeMethods.Wrapper.ClearErrorInfo();
                        break; // MDAC 72694
                    }
                    recordsAffected = AddRecordsAffected(recordsAffected, affected);

                    if (0 != (int)affected) {
                        loop = 0;
                    }
                    else if (2000 <= loop) { // MDAC 72126 (reason for more than 1000 iterations)
                        NextResultsInfinite(); // MDAC 72738
                        break;
                    }
                }
            }
            if (null != exceptions) {
                return OleDbException.CombineExceptions(exceptions);
            }
            return null;
        }
 internal static OleDbException NextResults(UnsafeNativeMethods.IMultipleResults imultipleResults, OleDbConnection connection, OleDbCommand command, out IntPtr recordsAffected)
 {
     recordsAffected = ADP.RecordsUnaffected;
     List<OleDbException> exceptions = null;
     if (imultipleResults != null)
     {
         int num = 0;
         while (true)
         {
             IntPtr ptr;
             object obj2;
             if ((command != null) && command.canceling)
             {
                 break;
             }
             Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB> DBRESULTFLAG_DEFAULT, IID_NULL\n");
             OleDbHResult result = imultipleResults.GetResult(ADP.PtrZero, ODB.DBRESULTFLAG_DEFAULT, ref ODB.IID_NULL, out ptr, out obj2);
             Bid.Trace("<oledb.IMultipleResults.GetResult|API|OLEDB|RET> %08X{HRESULT}, RecordAffected=%Id\n", result, ptr);
             if ((OleDbHResult.DB_S_NORESULT == result) || (OleDbHResult.E_NOINTERFACE == result))
             {
                 break;
             }
             if (connection != null)
             {
                 Exception exception = OleDbConnection.ProcessResults(result, connection, command);
                 if (exception != null)
                 {
                     OleDbException item = exception as OleDbException;
                     if (item == null)
                     {
                         throw exception;
                     }
                     if (exceptions == null)
                     {
                         exceptions = new List<OleDbException>();
                     }
                     exceptions.Add(item);
                 }
             }
             else if (result < OleDbHResult.S_OK)
             {
                 SafeNativeMethods.Wrapper.ClearErrorInfo();
                 break;
             }
             recordsAffected = AddRecordsAffected(recordsAffected, ptr);
             if (((int) ptr) != 0)
             {
                 num = 0;
             }
             else if (0x7d0 <= num)
             {
                 NextResultsInfinite();
                 break;
             }
             num++;
         }
     }
     if (exceptions != null)
     {
         return OleDbException.CombineExceptions(exceptions);
     }
     return null;
 }