Exemplo n.º 1
0
        private int ExecuteTableDirect(CommandBehavior behavior, out object executeResult) {
            this.commandBehavior = behavior;
            executeResult = null;

            OleDbHResult hr = OleDbHResult.S_OK;
            
            StringMemHandle sptr = null;
            bool            mustReleaseStringHandle = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                sptr = new StringMemHandle(ExpandCommandText());

                sptr.DangerousAddRef(ref mustReleaseStringHandle);

                if (mustReleaseStringHandle) {
                    tagDBID tableID = new tagDBID();
                    tableID.uGuid = Guid.Empty;
                    tableID.eKind = ODB.DBKIND_NAME;
                    tableID.ulPropid = sptr.DangerousGetHandle();

                    using(IOpenRowsetWrapper iopenRowset = _connection.IOpenRowset()) {
                        using(DBPropSet propSet = CommandPropertySets()) {
                            if (null != propSet) {

                                // MDAC 65279
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", ObjectID);
                                bool mustRelease = false;
                                RuntimeHelpers.PrepareConstrainedRegions();
                                try {
                                    propSet.DangerousAddRef(ref mustRelease);
                                    hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, propSet.PropertySetCount, propSet.DangerousGetHandle(), out executeResult);
                                }
                                finally {
                                    if (mustRelease) {
                                        propSet.DangerousRelease();
                                    }
                                }
                                    
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", hr);

                                if (OleDbHResult.DB_E_ERRORSOCCURRED == hr) {
                                    Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", ObjectID);
                                    hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                                    Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", hr);
                                }
                            }
                            else {
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", ObjectID);
                                hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", hr);
                            }
                        }
                    }
                }
            }
            finally {
                if (mustReleaseStringHandle) {
                    sptr.DangerousRelease();
                }
            }
            ProcessResults(hr);
            _recordsAffected = ADP.RecordsUnaffected;
            return ODB.ExecutedIRowset;
        }
 private int ExecuteTableDirect(CommandBehavior behavior, out object executeResult)
 {
     this.commandBehavior = behavior;
     executeResult = null;
     OleDbHResult result = OleDbHResult.S_OK;
     StringMemHandle handle = null;
     bool success = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         handle = new StringMemHandle(this.ExpandCommandText());
         handle.DangerousAddRef(ref success);
         if (success)
         {
             tagDBID pTableID = new tagDBID {
                 uGuid = Guid.Empty,
                 eKind = 2,
                 ulPropid = handle.DangerousGetHandle()
             };
             using (IOpenRowsetWrapper wrapper = this._connection.IOpenRowset())
             {
                 using (DBPropSet set = this.CommandPropertySets())
                 {
                     if (set != null)
                     {
                         Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                         bool flag2 = false;
                         RuntimeHelpers.PrepareConstrainedRegions();
                         try
                         {
                             set.DangerousAddRef(ref flag2);
                             result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, set.PropertySetCount, set.DangerousGetHandle(), out executeResult);
                         }
                         finally
                         {
                             if (flag2)
                             {
                                 set.DangerousRelease();
                             }
                         }
                         Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                         if (OleDbHResult.DB_E_ERRORSOCCURRED == result)
                         {
                             Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                             result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                             Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                         }
                     }
                     else
                     {
                         Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                         result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                         Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                     }
                 }
             }
         }
     }
     finally
     {
         if (success)
         {
             handle.DangerousRelease();
         }
     }
     this.ProcessResults(result);
     this._recordsAffected = ADP.RecordsUnaffected;
     return 1;
 }
Exemplo n.º 3
0
        private int ExecuteTableDirect(CommandBehavior behavior, out object executeResult)
        {
            this.commandBehavior = behavior;
            executeResult        = null;

            OleDbHResult hr = OleDbHResult.S_OK;

            StringMemHandle sptr = null;
            bool            mustReleaseStringHandle = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                sptr = new StringMemHandle(ExpandCommandText());

                sptr.DangerousAddRef(ref mustReleaseStringHandle);

                if (mustReleaseStringHandle)
                {
                    tagDBID tableID = new tagDBID();
                    tableID.uGuid    = Guid.Empty;
                    tableID.eKind    = ODB.DBKIND_NAME;
                    tableID.ulPropid = sptr.DangerousGetHandle();

                    using (IOpenRowsetWrapper iopenRowset = _connection.IOpenRowset())
                    {
                        using (DBPropSet propSet = CommandPropertySets())
                        {
                            if (null != propSet)
                            {
                                bool mustRelease = false;
                                RuntimeHelpers.PrepareConstrainedRegions();
                                try
                                {
                                    propSet.DangerousAddRef(ref mustRelease);
                                    hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, propSet.PropertySetCount, propSet.DangerousGetHandle(), out executeResult);
                                }
                                finally
                                {
                                    if (mustRelease)
                                    {
                                        propSet.DangerousRelease();
                                    }
                                }

                                if (OleDbHResult.DB_E_ERRORSOCCURRED == hr)
                                {
                                    hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                                }
                            }
                            else
                            {
                                hr = iopenRowset.Value.OpenRowset(ADP.PtrZero, tableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mustReleaseStringHandle)
                {
                    sptr.DangerousRelease();
                }
            }
            ProcessResults(hr);
            _recordsAffected = ADP.RecordsUnaffected;
            return(ODB.ExecutedIRowset);
        }
        private int ExecuteTableDirect(CommandBehavior behavior, out object executeResult)
        {
            this.commandBehavior = behavior;
            executeResult        = null;
            OleDbHResult    result  = OleDbHResult.S_OK;
            StringMemHandle handle  = null;
            bool            success = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                handle = new StringMemHandle(this.ExpandCommandText());
                handle.DangerousAddRef(ref success);
                if (success)
                {
                    tagDBID pTableID = new tagDBID {
                        uGuid    = Guid.Empty,
                        eKind    = 2,
                        ulPropid = handle.DangerousGetHandle()
                    };
                    using (IOpenRowsetWrapper wrapper = this._connection.IOpenRowset())
                    {
                        using (DBPropSet set = this.CommandPropertySets())
                        {
                            if (set != null)
                            {
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                                bool flag2 = false;
                                RuntimeHelpers.PrepareConstrainedRegions();
                                try
                                {
                                    set.DangerousAddRef(ref flag2);
                                    result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, set.PropertySetCount, set.DangerousGetHandle(), out executeResult);
                                }
                                finally
                                {
                                    if (flag2)
                                    {
                                        set.DangerousRelease();
                                    }
                                }
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                                if (OleDbHResult.DB_E_ERRORSOCCURRED == result)
                                {
                                    Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                                    result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                                    Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                                }
                            }
                            else
                            {
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID);
                                result = wrapper.Value.OpenRowset(ADP.PtrZero, pTableID, ADP.PtrZero, ref ODB.IID_IRowset, 0, IntPtr.Zero, out executeResult);
                                Bid.Trace("<oledb.IOpenRowset.OpenRowset|API|OLEDB|RET> %08X{HRESULT}", result);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (success)
                {
                    handle.DangerousRelease();
                }
            }
            this.ProcessResults(result);
            this._recordsAffected = ADP.RecordsUnaffected;
            return(1);
        }