# MTTransaction

The MTTransaction class contains methods you use to support transaction processing. It is used by plug-ins to directly control transaction state. In general, most plug-ins will never need to use this interface since the Rowset object returned by the MTSession object is fully transactional.

MTTransaction supports local and distributed transaction semantics as well as providing transactional rowset support. The initial implementation uses Microsoft DTC.

## Methods

BeginDistributed | Begins a distributed transaction
BeginLocal | Begins a local transaction
Init | Specifies a configuration path that contains dbaccess.xml
Commit | Saves all the transaction processing.
Export | Enables a server to participate in a distributed transaction.
GetRowset | Allows access to a rowset.
JoinDistributed | Joins a distributed transaction with the supplied cookie.
Rollback | Rolls back a transaction to previous state.

## Properties

DefaultTimeout | Returns the default transaction timeout set for COM+

## Example

Example to be provided in a future release of this online help system.

# Method Detail

## BeginDistributed

Begins a distributed transaction. Note that distributed transactions are expensive and require the use of a transaction coordinator.

### Visual Basic Syntax

Sub BeginDistributed()

### C++ Syntax

HRESULT BeginDistributed();

## BeginLocal

Begins a local transaction.

### Visual Basic Syntax

Sub BeginLocal()

### C++ Syntax

HRESULT BeginLocal();

## Commit

Commits a transaction, and saves all the transaction processing.

### Visual Basic Syntax

Sub Commit()

### C++ Syntax

HRESULT Commit();

## Export

The Export method enables a server to participate in a distributed transaction. This may be run only on a distributed transaction. A transaction cookie is returned.

### Visual Basic Syntax

Function Export(servername As String) As String

### C++ Syntax

HRESULT Export([in] BSTR servername, [out, retval] BSTR *apCookie);

### Arguments

servername

Name of the server to export the transaction to.

### Return Value

A transaction cookie. It is often passed between hosts as a property through the remeter plug-in, or by other communication means.

## GetRowset

GetRowset returns a rowset pointer. Use this method to update, insert, and perform other actions on the database.

Typically, programmers will use the MTSession method GetRowset; only programmers needing to explicitly manage transactions will use this method.

### Visual Basic Syntax

Function GetRowset() As IMTSQLRowset

### C++ Syntax

HRESULT GetRowset([out, retval] IMTSQLRowset *pSQLRowset);

### Return Value

Returns a pointer to a rowset.

## Init

Specifies a configuration path that contains a dbaccess.xml file. Essentially, this determines the database type and connection technology (such as OLEDB, ADO, ADO-DSN).

### Visual Basic Syntax

Sub Init(Configfile As String)

### C++ Syntax

HRESULT Init([in] BSTR Configfile);

### Arguments

Configfile

Complete pathname for the dbaccess.xml file.

## JoinDistributed

This method enlists in a distributed transaction, started by another machine or process, with the supplied cookie.

### Visual Basic Syntax

Sub JoinDistributed(cookie As String)

### C++ Syntax

HRESULT JoinDistributed([in] BSTR cookie);

### Arguments

cookie

A transaction cookie that has been created through the Export method.

## Rollback

Aborts and rolls back a transaction, and restores the data source to the state it was in before the transaction began.

### Visual Basic Syntax

Sub Rollback()

### C++ Syntax

HRESULT Rollback();

# Property Detail

## DefaultTimeout

This method retrieves the timeout set in COM+/MTS. The pipeline's session object uses this timeout when beginning transactions.

### Visual Basic Syntax

Function DefaultTimeout as Long

### C++ Syntax

HRESULT DefaultTimeout([out, retval] long *pVal);

### Return Value

The default timeout value.