예제 #1
0
        internal void ResetValue()
        {
            this._value = null;
            StringMemHandle handle = this._sptr;

            this._sptr = null;
            if (handle != null)
            {
                handle.Dispose();
            }
            if (this._pinnedBuffer.IsAllocated)
            {
                this._pinnedBuffer.Free();
            }
        }
예제 #2
0
        internal readonly StringMemHandle dbString; // ptr to native allocated memory for dataSourceType string

        private NativeDBType(Byte maxpre, int fixlen, bool isfixed, bool islong, OleDbType enumOleDbType, short dbType, string dbstring, Type dataType, short wType, DbType enumDbType)
        {
            this.enumOleDbType  = enumOleDbType;
            this.dbType         = dbType;
            this.dbPart         = (-1 == fixlen) ? VarblDbPart : FixedDbPart;
            this.isfixed        = isfixed;
            this.islong         = islong;
            this.maxpre         = maxpre;
            this.fixlen         = fixlen;
            this.wType          = wType;
            this.dataSourceType = dbstring;
            this.dbString       = new StringMemHandle(dbstring);
            this.dataType       = dataType;
            this.enumDbType     = enumDbType;
        }
예제 #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) {

                                // 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 void GetRowValue() {
            Debug.Assert(null != _irow, "GetRowValue: null IRow");
            Debug.Assert(null != _metadata, "GetRowValue: null MetaData");

            Bindings bindings = _bindings[_nextAccessorForRetrieval];
            ColumnBinding[] columnBindings = bindings.ColumnBindings();
            RowBinding rowBinding = bindings.RowBinding();
            Debug.Assert(_nextValueForRetrieval <= columnBindings[0].Index, "backwards retrieval");

            bool mustReleaseBinding = false;
            bool[] mustRelease = new bool[columnBindings.Length];
            StringMemHandle[] sptr = new StringMemHandle[columnBindings.Length];

            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                for (int i = 0; i < columnBindings.Length; ++i) {
                    bindings.CurrentIndex = i;

                    sptr[i] = null;
                    MetaData info = _metadata[columnBindings[i].Index];
                    if ((ODB.DBKIND_GUID_NAME == info.kind) || (ODB.DBKIND_NAME == info.kind)) {
                        sptr[i] = new StringMemHandle(info.idname);
                        columnBindings[i]._sptr = sptr[i];
                    }

                    sptr[i].DangerousAddRef(ref mustRelease[i]);

                    IntPtr ulPropid = ((null != sptr[i]) ? sptr[i].DangerousGetHandle() : info.propid);
                    bindings.GuidKindName(info.guid, info.kind, ulPropid);
                }

                OleDbHResult hr;
                tagDBCOLUMNACCESS[] access = bindings.DBColumnAccess;

                rowBinding.DangerousAddRef(ref mustReleaseBinding);
                rowBinding.StartDataBlock();                

                UnsafeNativeMethods.IRow irow = IRow();

                Bid.Trace("<oledb.IRow.GetColumns|API|OLEDB> %d#\n", ObjectID);                
                hr = irow.GetColumns((IntPtr)access.Length, access);
                Bid.Trace("<oledb.IRow.GetColumns|API|OLEDB|RET> %08X{HRESULT}\n", hr);
            }
            finally {
                if (mustReleaseBinding) {
                    rowBinding.DangerousRelease();
                }
                for (int i = 0; i < mustRelease.Length; i++) {
                    if (mustRelease[i]) {
                        sptr[i].DangerousRelease();
                    }
                }
            }
            _nextAccessorForRetrieval++;
        }
예제 #5
0
        internal readonly StringMemHandle dbString;  // ptr to native allocated memory for dataSourceType string

        private NativeDBType(Byte maxpre, int fixlen, bool isfixed, bool islong, OleDbType enumOleDbType, short dbType, string dbstring, Type dataType, short wType, DbType enumDbType) {
            this.enumOleDbType  = enumOleDbType;
            this.dbType    = dbType;
            this.dbPart    = (-1 == fixlen) ? VarblDbPart : FixedDbPart;
            this.isfixed   = isfixed;
            this.islong    = islong;
            this.maxpre    = maxpre;
            this.fixlen    = fixlen;
            this.wType     = wType;
            this.dataSourceType = dbstring;
            this.dbString  = new StringMemHandle(dbstring);
            this.dataType  = dataType;
            this.enumDbType = enumDbType;
        }
예제 #6
0
        internal void ResetValue() {
            _value = null;

            StringMemHandle sptr = _sptr;
            _sptr = null;

            if (null != sptr) {
                sptr.Dispose();
            }

            if (_pinnedBuffer.IsAllocated) {
                _pinnedBuffer.Free();
            }
        }
예제 #7
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 void GetRowValue()
 {
     Bindings bindings = this._bindings[this._nextAccessorForRetrieval];
     ColumnBinding[] bindingArray = bindings.ColumnBindings();
     RowBinding binding = bindings.RowBinding();
     bool success = false;
     bool[] flagArray = new bool[bindingArray.Length];
     StringMemHandle[] handleArray = new StringMemHandle[bindingArray.Length];
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         for (int i = 0; i < bindingArray.Length; i++)
         {
             bindings.CurrentIndex = i;
             handleArray[i] = null;
             System.Data.OleDb.MetaData data = this._metadata[bindingArray[i].Index];
             if ((data.kind == 0) || (2 == data.kind))
             {
                 handleArray[i] = new StringMemHandle(data.idname);
                 bindingArray[i]._sptr = handleArray[i];
             }
             handleArray[i].DangerousAddRef(ref flagArray[i]);
             IntPtr propid = (handleArray[i] != null) ? handleArray[i].DangerousGetHandle() : data.propid;
             bindings.GuidKindName(data.guid, data.kind, propid);
         }
         tagDBCOLUMNACCESS[] dBColumnAccess = bindings.DBColumnAccess;
         binding.DangerousAddRef(ref success);
         binding.StartDataBlock();
         System.Data.Common.UnsafeNativeMethods.IRow row = this.IRow();
         Bid.Trace("<oledb.IRow.GetColumns|API|OLEDB> %d#\n", this.ObjectID);
         OleDbHResult columns = row.GetColumns((IntPtr) dBColumnAccess.Length, dBColumnAccess);
         Bid.Trace("<oledb.IRow.GetColumns|API|OLEDB|RET> %08X{HRESULT}\n", columns);
     }
     finally
     {
         if (success)
         {
             binding.DangerousRelease();
         }
         for (int j = 0; j < flagArray.Length; j++)
         {
             if (flagArray[j])
             {
                 handleArray[j].DangerousRelease();
             }
         }
     }
     this._nextAccessorForRetrieval++;
 }
 internal void ResetValue()
 {
     this._value = null;
     StringMemHandle handle = this._sptr;
     this._sptr = null;
     if (handle != null)
     {
         handle.Dispose();
     }
     if (this._pinnedBuffer.IsAllocated)
     {
         this._pinnedBuffer.Free();
     }
 }
 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;
 }
        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);
        }