private bool PropertiesOnCommand(bool throwNotSupported) { if (null != _icommandText) { return(true); } Debug.Assert(!_isPrepared, "null command isPrepared"); OleDbConnection connection = _connection; if (null == connection) { connection.CheckStateOpen(ODB.Properties); } if (!_trackingForClose) { _trackingForClose = true; connection.AddWeakReference(this, OleDbReferenceCollection.CommandTag); } _icommandText = connection.ICommandText(); if (null == _icommandText) { if (throwNotSupported || HasParameters()) { throw ODB.CommandTextNotSupported(connection.Provider, null); } return(false); } using (DBPropSet propSet = CommandPropertySets()) { if (null != propSet) { UnsafeNativeMethods.ICommandProperties icommandProperties = ICommandProperties(); OleDbHResult hr = icommandProperties.SetProperties(propSet.PropertySetCount, propSet); if (hr < 0) { SafeNativeMethods.Wrapper.ClearErrorInfo(); } } } return(true); }
private bool PropertiesOnCommand(bool throwNotSupported) { if (this._icommandText == null) { OleDbConnection connection = this._connection; if (connection == null) { connection.CheckStateOpen("Properties"); } if (!this._trackingForClose) { this._trackingForClose = true; connection.AddWeakReference(this, 1); } this._icommandText = connection.ICommandText(); if (this._icommandText == null) { if (throwNotSupported || this.HasParameters()) { throw ODB.CommandTextNotSupported(connection.Provider, null); } return(false); } using (DBPropSet set = this.CommandPropertySets()) { if (set != null) { System.Data.Common.UnsafeNativeMethods.ICommandProperties properties = this.ICommandProperties(); Bid.Trace("<oledb.ICommandProperties.SetProperties|API|OLEDB> %d#\n", this.ObjectID); OleDbHResult result = properties.SetProperties(set.PropertySetCount, set); Bid.Trace("<oledb.ICommandProperties.SetProperties|API|OLEDB|RET> %08X{HRESULT}\n", result); if (result < OleDbHResult.S_OK) { SafeNativeMethods.Wrapper.ClearErrorInfo(); } } } } return(true); }