ADO BeginTrans, CommitTran, and RollbackTrans methods

Definition and Usage

These three methods are used with the Connection object to save or cancel changes made to the data source.

Note:Not all providers support transactions.

Note:The BeginTrans, CommitTrans, and RollbackTrans methods are invalid on the client Connection object.

BeginTrans

The BeginTrans method can start a new transaction.

CommitTrans

The CommitTrans method saves all changes made since the last BeginTrans method call and ends the current transaction. It may also start a new transaction.

RollbackTrans

The RollbackTrans method cancels all changes since the last BeginTrans method call and ends the transaction. It may also start a new transaction.

Description

For providers that support nested transactions, calling the BeginTrans method within an open transaction starts a new nested transaction. The return value indicates the nesting level: a return value of '1' indicates that a top-level transaction has been opened (i.e., this transaction is not nested within another transaction), a return value of '2' indicates that a second-level transaction has been opened (nested within the top-level transaction), and so on. Calling CommitTrans or RollbackTrans only affects the most recently opened transaction; the current transaction must be closed or rolled back before handling any higher-level transactions.

Syntax

level=objconn.BeginTrans()
objconn.BeginTrans
objconn.CommitTrans
objconn.RollbackTrans