ITransaction::Commit

Commits a transaction.

HRESULT Commit(
   BOOL      fRetaining,
   DWORD   grfTC,
   DWORD   grfRM);

Parameters

fRetaining

[in]
Whether the commit is retaining or nonretaining.

grfTC

[in]
Values taken from the enumeration XACTTC. Values that may be specified in grfTC are as follows. These values are mutually exclusive.

Flag Description
XACTTC_
ASYNC_PHASEONE
When this flag is specified, an asynchronous commit is performed.
XACTTC_
SYNC_
PHASEONE
When this flag is specified, the call to Commit returns after phase one of the two-phase commit protocol.
XACTTC_
SYNC_
PHASETWO
When this flag is specified, the call to Commit returns after phase two of the two-phase commit protocol.
XACTTC_
SYNC
Synonym for XACTTC_SYNC_PHASETWO.

grfRM

[in]
Must be zero.

Return Code

S_OK
The transaction was successfully committed.

XACT_S_ASYNC
An asynchronous commit was specified. The commit operation has begun but its outcome is not yet known. When the transaction is complete, notification will be sent by ITransactionOutcomeEvents.

E_FAIL
A provider-specific error occurred. The transaction was aborted.

E_UNEXPECTED
An unexpected error occurred. The transaction status is unknown.

XACT_E_ABORTED
The transaction was aborted before Commit was called.

XACT_E_ALREADYINPROGRESS
A commit or abort operation was already in progress. This call was ignored.

XACT_E_CANTRETAIN
Retaining commit is not supported or a new unit of work could not be created. The commit succeeded and the session is in autocommit mode.

XACT_E_COMMITFAILED
The transaction failed to commit for an unknown reason. The transaction was aborted.

XACT_E_CONNECTION_DOWN
The connection to the transaction manager failed. The transaction was aborted.

XACT_E_INDOUBT
The transaction status is in doubt. A communication failure occurred or a transaction manager or resource manager has failed.

XACT_E_NOTRANSACTION
Unable to commit the transaction because it had already been implicitly or explicitly committed or aborted. This call was ignored.

XACT_E_NOTSUPPORTED
An invalid combination of commit flags was specified or grfRM was not equal to zero. This call was ignored.

Comments

The following table shows how values of the fRetaining parameter and DBPROP_COMMITPRESERVE affect the rowset state and transaction mode.

DBPROP_
COMMIT
PRESERVE


fRetaining

Rowset state after
commit

Resulting transaction mode
of session
FALSE FALSE zombie implicit / autocommit
FALSE TRUE zombie explicit / manual
TRUE FALSE preserved implicit / autocommit
TRUE TRUE preserved explicit / manual

If Commit fails for any reason that results in an aborted transaction, the session is left in autocommit mode.

See Also

ITransaction::Abort