Visual Basic Reference

MTSTransactionMode Property

See Also    Example    Applies To

Specifies the transactional behavior of a class. This property is only used by components running in the Microsoft Transaction Server, and has no effect if the component is run outside of the Transaction Server.

Syntax

object.MTSTransactionMode [= value]

The MTSTransactionMode property has these parts:

Part Description
object An object expression that evaluates to an item in the Applies To list.
value An integer or constant specifying the transactional behavior of a class.

Settings

The settings for value are:

Constant Value Description
NotAnMTSObject 0 (Default) The component doesn't support Microsoft Transaction Server.
NoTransactions 1 Does not support transactions. This value indicates that the component's objects do not run within the scope of transactions. When a new object is created, its object context is created without a transaction, regardless of whether the client has a transaction.
RequiresTransaction 2 This value indicates that the component's objects must execute within the scope of a transaction. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, MTS automatically creates a new transaction for the object.
UsesTransaction 3 This value indicates that the component's objects can execute within the scope of their client's transactions. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, the new context is also created without one.
RequiresNewTransaction 4 This value indicates that the component's objects must execute within their own transactions. When a new object is created, MTS automatically creates a new transaction for the object, regardless of whether its client has a transaction.

Remarks

The Microsoft Transaction Server uses the MTSTransactionMode property during object creation to determine whether the object should be created to execute within a transaction, and whether a transaction is required or optional.

Most MTS components are declared as either UsesTransactions or RequiresTransaction. These values allow an object to execute within the scope of its client's transaction. You can see the difference between these values when an object is created from a context that does not have a transaction. If the component's transaction attribute is UsesTransactions, the new object runs without a transaction. If it is declared as RequiresTransaction, MTS automatically initiates a transaction for the new object.

Declaring a component as RequiresNewTransaction is similar to using RequiresTransaction in that the component's objects are guaranteed to execute within transactions. However, when you declare the transaction attribute this way, an object never runs inside the scope of its client's transaction. Instead, the system always creates independent transactions for the new objects. For example, you can use this attribute for auditing components that record work done on behalf of another transaction regardless of whether the original transaction commits or aborts.