Пример #1
0
 internal void SetDataSourcePropertyValue(Guid propertySet, int propertyID, string description, bool required, object value)
 {
     this.CheckStateOpen("SetProperties");
     using (IDBPropertiesWrapper wrapper = this.IDBProperties())
     {
         using (DBPropSet set = DBPropSet.CreateProperty(propertySet, propertyID, required, value))
         {
             Bid.Trace("<oledb.IDBProperties.SetProperties|API|OLEDB> %d#\n", this.ObjectID);
             OleDbHResult result = wrapper.Value.SetProperties(set.PropertySetCount, set);
             Bid.Trace("<oledb.IDBProperties.SetProperties|API|OLEDB|RET> %08X{HRESULT}\n", result);
             if (result < OleDbHResult.S_OK)
             {
                 Exception inner = ProcessResults(result, null, this);
                 if (OleDbHResult.DB_E_ERRORSOCCURRED == result)
                 {
                     StringBuilder builder      = new StringBuilder();
                     tagDBPROP[]   gdbpropArray = set.GetPropertySet(0, out propertySet);
                     ODB.PropsetSetFailure(builder, description, gdbpropArray[0].dwStatus);
                     inner = ODB.PropsetSetFailure(builder.ToString(), inner);
                 }
                 if (inner != null)
                 {
                     throw inner;
                 }
             }
             else
             {
                 SafeNativeMethods.Wrapper.ClearErrorInfo();
             }
         }
     }
 }
Пример #2
0
        internal void SetDataSourcePropertyValue(Guid propertySet, int propertyID, string description, bool required, object value)
        {
            CheckStateOpen(ADP.SetProperties);
            OleDbHResult hr;

            using (IDBPropertiesWrapper idbProperties = IDBProperties())
            {
                using (DBPropSet propSet = DBPropSet.CreateProperty(propertySet, propertyID, required, value))
                {
                    hr = idbProperties.Value.SetProperties(propSet.PropertySetCount, propSet);

                    if (hr < 0)
                    {
                        Exception e = OleDbConnection.ProcessResults(hr, null, this);
                        if (OleDbHResult.DB_E_ERRORSOCCURRED == hr)
                        {
                            StringBuilder builder = new StringBuilder();
                            Debug.Assert(1 == propSet.PropertySetCount, "too many PropertySets");

                            tagDBPROP[] dbprops = propSet.GetPropertySet(0, out propertySet);
                            Debug.Assert(1 == dbprops.Length, "too many Properties");

                            ODB.PropsetSetFailure(builder, description, dbprops[0].dwStatus);

                            e = ODB.PropsetSetFailure(builder.ToString(), e);
                        }
                        if (null != e)
                        {
                            throw e;
                        }
                    }
                    else
                    {
                        SafeNativeMethods.Wrapper.ClearErrorInfo();
                    }
                }
            }
        }