public override void Commit() { OdbcConnection connection = _connection; if (null == connection) { throw ADP.TransactionZombied(this); } connection.CheckState(ADP.CommitTransaction); // MDAC 68289 //Note: SQLEndTran success if not actually in a transaction, so we have to throw //since the IDbTransaciton spec indicates this is an error for the managed packages if (null == _handle) { throw ODBC.NotInTransaction(); } ODBC32.RetCode retcode = _handle.CompleteTransaction(ODBC32.SQL_COMMIT); if (retcode == ODBC32.RetCode.ERROR) { //If an error has occurred, we will throw an exception in HandleError, //and leave the transaction active for the user to retry connection.HandleError(_handle, retcode); } //Transaction is complete... connection.LocalTransaction = null; _connection = null; _handle = null; }
protected override void Dispose(bool disposing) { if (disposing) { OdbcConnectionHandle hrHandle = this._handle; this._handle = null; if (hrHandle != null) { try { ODBC32.RetCode retcode = hrHandle.CompleteTransaction(1); if ((retcode == ODBC32.RetCode.ERROR) && (this._connection != null)) { ADP.TraceExceptionWithoutRethrow(this._connection.HandleErrorNoThrow(hrHandle, retcode)); } } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } } } if ((this._connection != null) && this._connection.IsOpen) { this._connection.LocalTransaction = null; } this._connection = null; this._isolevel = System.Data.IsolationLevel.Unspecified; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { OdbcConnectionHandle handle = _handle; _handle = null; if (null != handle) { try { ODBC32.RetCode retcode = handle.CompleteTransaction(ODBC32.SQL_ROLLBACK); if (retcode == ODBC32.RetCode.ERROR) { //don't throw an exception here, but trace it so it can be logged if (_connection != null) { Exception e = _connection.HandleErrorNoThrow(handle, retcode); ADP.TraceExceptionWithoutRethrow(e); } } } catch (Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } } } if (_connection != null) { if (_connection.IsOpen) { _connection.LocalTransaction = null; } } _connection = null; _isolevel = IsolationLevel.Unspecified; } base.Dispose(disposing); }