/// <include file='doc\OleDbTransaction.uex' path='docs/doc[@for="OleDbTransaction.Begin"]/*' /> public OleDbTransaction Begin(IsolationLevel isolevel) { OleDbConnection.OleDbPermission.Demand(); // MDAC 81476 if (null == this.localTransaction) { throw ADP.TransactionZombied(this); } parentConnection.CheckStateOpen(ADP.BeginTransaction); OleDbTransaction transaction = new OleDbTransaction(this.parentConnection); this.weakTransaction = new WeakReference(transaction); transaction.BeginInternal(this.localTransaction, isolevel); transaction.parentTransaction = this; return(transaction); }
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 void ValidateConnection(string method) { if (null == _connection) { throw ADP.ConnectionRequired(method); } _connection.CheckStateOpen(method); // user attempting to execute the command while the first dataReader hasn't returned // use the connection reference collection to see if the dataReader referencing this // command has been garbage collected or not. if (_hasDataReader) { if (_connection.HasLiveReader(this)) { throw ADP.OpenReaderExists(); } _hasDataReader = false; } }
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); }