Beispiel #1
0
        private DBPropSet CommandPropertySets()
        {
            DBPropSet propSet = null;

            bool keyInfo = (0 != (CommandBehavior.KeyInfo & this.commandBehavior));

            // always set the CommandTimeout value?
            int count = (_executeQuery ? (keyInfo ? 4 : 2) : 1);

            if (0 < count)
            {
                propSet = new DBPropSet(1);

                tagDBPROP[] dbprops = new tagDBPROP[count];

                dbprops[0] = new tagDBPROP(ODB.DBPROP_COMMANDTIMEOUT, false, CommandTimeout);

                if (_executeQuery)
                {
                    // 'Microsoft.Jet.OLEDB.4.0' default is DBPROPVAL_AO_SEQUENTIAL
                    dbprops[1] = new tagDBPROP(ODB.DBPROP_ACCESSORDER, false, ODB.DBPROPVAL_AO_RANDOM);

                    if (keyInfo)
                    {
                        // 'Unique Rows' property required for SQLOLEDB to retrieve things like 'BaseTableName'
                        dbprops[2] = new tagDBPROP(ODB.DBPROP_UNIQUEROWS, false, keyInfo);

                        // otherwise 'Microsoft.Jet.OLEDB.4.0' doesn't support IColumnsRowset
                        dbprops[3] = new tagDBPROP(ODB.DBPROP_IColumnsRowset, false, true);
                    }
                }
                propSet.SetPropertySet(0, OleDbPropertySetGuid.Rowset, dbprops);
            }
            return(propSet);
        }
Beispiel #2
0
        internal static DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value)
        {
            tagDBPROP gdbprop = new tagDBPROP(propertyId, required, value);
            DBPropSet set     = new DBPropSet(1);

            set.SetPropertySet(0, propertySet, new tagDBPROP[] { gdbprop });
            return(set);
        }
Beispiel #3
0
        static internal DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value)
        {
            tagDBPROP dbprop      = new tagDBPROP(propertyId, required, value);
            DBPropSet propertyset = new DBPropSet(1);

            propertyset.SetPropertySet(0, propertySet, new tagDBPROP[1] {
                dbprop
            });
            return(propertyset);
        }
Beispiel #4
0
        internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset)
        {
            if ((index < 0) || (PropertySetCount <= index))
            {
                if (lastErrorFromProvider != null)
                {
                    // add extra error information for CSS/stress troubleshooting.
                    // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1.
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider);
                }
                else
                {
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
                }
            }

            tagDBPROPSET propset = new tagDBPROPSET();

            tagDBPROP[] properties = null;

            bool mustRelease = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                DangerousAddRef(ref mustRelease);
                IntPtr propertySetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET);
                Marshal.PtrToStructure(propertySetPtr, propset);
                propertyset = propset.guidPropertySet;

                properties = new tagDBPROP[propset.cProperties];
                for (int i = 0; i < properties.Length; ++i)
                {
                    properties[i] = new tagDBPROP();
                    IntPtr ptr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP);
                    Marshal.PtrToStructure(ptr, properties[i]);
                }
            }
            finally
            {
                if (mustRelease)
                {
                    DangerousRelease();
                }
            }
            return(properties);
        }
Beispiel #5
0
        internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset)
        {
            if ((index < 0) || (this.PropertySetCount <= index))
            {
                if (this.lastErrorFromProvider != null)
                {
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider);
                }
                throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
            }
            tagDBPROPSET structure = new tagDBPROPSET();

            tagDBPROP[] gdbpropArray = null;
            bool        success      = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                base.DangerousAddRef(ref success);
                Marshal.PtrToStructure(ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET), structure);
                propertyset  = structure.guidPropertySet;
                gdbpropArray = new tagDBPROP[structure.cProperties];
                for (int i = 0; i < gdbpropArray.Length; i++)
                {
                    gdbpropArray[i] = new tagDBPROP();
                    Marshal.PtrToStructure(ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP), gdbpropArray[i]);
                }
            }
            finally
            {
                if (success)
                {
                    base.DangerousRelease();
                }
            }
            return(gdbpropArray);
        }
        private DBPropSet CommandPropertySets()
        {
            DBPropSet set  = null;
            bool      flag = CommandBehavior.Default != (CommandBehavior.KeyInfo & this.commandBehavior);
            int       num  = this._executeQuery ? (flag ? 4 : 2) : 1;

            if (0 < num)
            {
                set = new DBPropSet(1);
                tagDBPROP[] properties = new tagDBPROP[num];
                properties[0] = new tagDBPROP(0x22, false, this.CommandTimeout);
                if (this._executeQuery)
                {
                    properties[1] = new tagDBPROP(0xe7, false, 2);
                    if (flag)
                    {
                        properties[2] = new tagDBPROP(0xee, false, flag);
                        properties[3] = new tagDBPROP(0x7b, false, true);
                    }
                }
                set.SetPropertySet(0, OleDbPropertySetGuid.Rowset, properties);
            }
            return(set);
        }
Beispiel #7
0
 static internal DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value) {
     tagDBPROP dbprop = new tagDBPROP(propertyId, required, value);
     DBPropSet propertyset = new DBPropSet(1);
     propertyset.SetPropertySet(0, propertySet, new tagDBPROP[1] { dbprop });
     return propertyset;
 }
Beispiel #8
0
        internal void SetPropertySet(int index, Guid propertySet, tagDBPROP[] properties) {
            if ((index < 0) || (PropertySetCount <= index)) {
                if (lastErrorFromProvider != null) {
                    // VSDD 621427: add extra error information for CSS/stress troubleshooting.
                    // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1.
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider);
                }
                else {
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
                }
            }
            Debug.Assert(Guid.Empty != propertySet, "invalid propertySet");
            Debug.Assert((null != properties) && (0 < properties.Length), "invalid properties");

            IntPtr countOfBytes = (IntPtr)(properties.Length * ODB.SizeOf_tagDBPROP);
            tagDBPROPSET propset = new tagDBPROPSET(properties.Length, propertySet);

            bool mustRelease = false;
            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                DangerousAddRef(ref mustRelease);

                IntPtr propsetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET);

                RuntimeHelpers.PrepareConstrainedRegions();
                try {} finally {
                    // must allocate and clear the memory without interruption
                    propset.rgProperties = SafeNativeMethods.CoTaskMemAlloc(countOfBytes);
                    if (ADP.PtrZero != propset.rgProperties) {
                        // clearing is important so that we don't treat existing
                        // garbage as important information during releaseHandle
                        SafeNativeMethods.ZeroMemory(propset.rgProperties, countOfBytes);
                        
                        // writing the structure to native memory so that it knows to free the referenced pointers
                        Marshal.StructureToPtr(propset, propsetPtr, false/*deleteold*/);
                    }
                }
                if (ADP.PtrZero == propset.rgProperties) {
                    throw new OutOfMemoryException();
                }

                for(int i = 0; i < properties.Length; ++i) {
                    Debug.Assert(null != properties[i], "null tagDBPROP " + i.ToString(CultureInfo.InvariantCulture));
                    IntPtr propertyPtr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP);
                    Marshal.StructureToPtr(properties[i], propertyPtr, false/*deleteold*/);
                }
            }
            finally {
                if (mustRelease) {
                    DangerousRelease();
                }
            }
        }
Beispiel #9
0
        internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset) {
            if ((index < 0) || (PropertySetCount <= index)) {
                if (lastErrorFromProvider != null)
                {
                    // VSDD 621427: add extra error information for CSS/stress troubleshooting.
                    // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1.
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider);
                }
                else {
                    throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
                }
            }

            tagDBPROPSET propset = new tagDBPROPSET();
            tagDBPROP[] properties = null;

            bool mustRelease = false;
            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                DangerousAddRef(ref mustRelease);
                IntPtr propertySetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET);
                Marshal.PtrToStructure(propertySetPtr, propset);
                propertyset = propset.guidPropertySet;

                properties = new tagDBPROP[propset.cProperties];
                for(int i = 0; i < properties.Length; ++i) {
                    properties[i] = new tagDBPROP();
                    IntPtr ptr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP);
                    Marshal.PtrToStructure(ptr, properties[i]);
                }
            }
            finally {
                if (mustRelease) {
                    DangerousRelease();
                }
            }
            return properties;
        }
        private DBPropSet CommandPropertySets() {
            DBPropSet propSet = null;

            bool keyInfo = (0 != (CommandBehavior.KeyInfo & this.commandBehavior));

            // always set the CommandTimeout value?
            int count = (_executeQuery ? (keyInfo ? 4 : 2) : 1);

            if (0 < count) {
                propSet = new DBPropSet(1);

                tagDBPROP[] dbprops = new tagDBPROP[count];

                dbprops[0] = new tagDBPROP(ODB.DBPROP_COMMANDTIMEOUT, false, CommandTimeout);

                if (_executeQuery) {
                    // 'Microsoft.Jet.OLEDB.4.0' default is DBPROPVAL_AO_SEQUENTIAL
                    dbprops[1] = new tagDBPROP(ODB.DBPROP_ACCESSORDER, false, ODB.DBPROPVAL_AO_RANDOM); // MDAC 73030

                    if (keyInfo) {
                        // 'Unique Rows' property required for SQLOLEDB to retrieve things like 'BaseTableName'
                        dbprops[2] = new tagDBPROP(ODB.DBPROP_UNIQUEROWS, false, keyInfo);

                        // otherwise 'Microsoft.Jet.OLEDB.4.0' doesn't support IColumnsRowset
                        dbprops[3] = new tagDBPROP(ODB.DBPROP_IColumnsRowset, false, true);
                    }
                }
                propSet.SetPropertySet(0, OleDbPropertySetGuid.Rowset, dbprops);
            }
            return propSet;
        }
 private DBPropSet CommandPropertySets()
 {
     DBPropSet set = null;
     bool flag = CommandBehavior.Default != (CommandBehavior.KeyInfo & this.commandBehavior);
     int num = this._executeQuery ? (flag ? 4 : 2) : 1;
     if (0 < num)
     {
         set = new DBPropSet(1);
         tagDBPROP[] properties = new tagDBPROP[num];
         properties[0] = new tagDBPROP(0x22, false, this.CommandTimeout);
         if (this._executeQuery)
         {
             properties[1] = new tagDBPROP(0xe7, false, 2);
             if (flag)
             {
                 properties[2] = new tagDBPROP(0xee, false, flag);
                 properties[3] = new tagDBPROP(0x7b, false, true);
             }
         }
         set.SetPropertySet(0, OleDbPropertySetGuid.Rowset, properties);
     }
     return set;
 }
 internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset)
 {
     if ((index < 0) || (this.PropertySetCount <= index))
     {
         if (this.lastErrorFromProvider != null)
         {
             throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider);
         }
         throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
     }
     tagDBPROPSET structure = new tagDBPROPSET();
     tagDBPROP[] gdbpropArray = null;
     bool success = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         base.DangerousAddRef(ref success);
         Marshal.PtrToStructure(ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET), structure);
         propertyset = structure.guidPropertySet;
         gdbpropArray = new tagDBPROP[structure.cProperties];
         for (int i = 0; i < gdbpropArray.Length; i++)
         {
             gdbpropArray[i] = new tagDBPROP();
             Marshal.PtrToStructure(ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP), gdbpropArray[i]);
         }
     }
     finally
     {
         if (success)
         {
             base.DangerousRelease();
         }
     }
     return gdbpropArray;
 }
 internal static DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value)
 {
     tagDBPROP gdbprop = new tagDBPROP(propertyId, required, value);
     DBPropSet set = new DBPropSet(1);
     set.SetPropertySet(0, propertySet, new tagDBPROP[] { gdbprop });
     return set;
 }
 internal void SetPropertySet(int index, Guid propertySet, tagDBPROP[] properties)
 {
     if ((index < 0) || (this.PropertySetCount <= index))
     {
         if (this.lastErrorFromProvider != null)
         {
             throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider);
         }
         throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer);
     }
     IntPtr cb = (IntPtr) (properties.Length * ODB.SizeOf_tagDBPROP);
     tagDBPROPSET structure = new tagDBPROPSET(properties.Length, propertySet);
     bool success = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         base.DangerousAddRef(ref success);
         IntPtr ptr = ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET);
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
         }
         finally
         {
             structure.rgProperties = SafeNativeMethods.CoTaskMemAlloc(cb);
             if (ADP.PtrZero != structure.rgProperties)
             {
                 SafeNativeMethods.ZeroMemory(structure.rgProperties, cb);
                 Marshal.StructureToPtr(structure, ptr, false);
             }
         }
         if (ADP.PtrZero == structure.rgProperties)
         {
             throw new OutOfMemoryException();
         }
         for (int i = 0; i < properties.Length; i++)
         {
             IntPtr ptr2 = ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP);
             Marshal.StructureToPtr(properties[i], ptr2, false);
         }
     }
     finally
     {
         if (success)
         {
             base.DangerousRelease();
         }
     }
 }