Platform SDK: Transaction Server

Abort, Commit Methods Example

[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]

Dim objTxCtx As TransactionContext
Dim objMyObject As MyCompany.MyObject
Dim userCanceled As Boolean

' Get TransactionContext.
Set objTxCtx = _
    CreateObject("TxCtx.TransactionContext")

' Create an instance of some component.
Set objMyObject= _
    objTxCtx.CreateInstance("MyCompany.MyObject")

' Do some work here.

' If something goes wrong, abort the transaction.
If userCanceled Then
    objTxCtx.Abort

' Otherwise, commit it.
Else
    objTxCtx.Commit
End If