Transactions Property

Applies To

Connection object, Database object, Dynaset-Type Recordset object, Forward-Only-Type Recordset object, Recordset object, Snapshot-Type Recordset object, Table-Type Recordset object.

Description

Returns a value that indicates whether an object supports transactions.

Return Values

The return value is a Boolean data type that is True if the object supports transactions.

Remarks

In an ODBCDirect workspace, the Transactions property is available on Connection and Database objects, and indicates whether or not the ODBC driver you are using supports transactions.

In a Microsoft Jet workspace, you can also use the Transactions property with dynaset- or table-type Recordset objects. Snapshot- and forward-only-type Recordset objects always return False.

If a dynaset- or table-type Recordset is based on a Microsoft Jet database engine table, the Transactions property is True and you can use transactions. Other database engines may not support transactions. For example, you can't use transactions in a dynaset-type Recordset object based on a Paradox table.

Check the Transactions property before using the BeginTrans method on the Recordset object's Workspace object to make sure that transactions are supported. Using the BeginTrans, CommitTrans, or Rollback methods on an unsupported object has no effect.

See Also

BeginTrans, CommitTrans, Rollback methods.

Example

This example demonstrates the Transactions property in Microsoft Jet and ODBCDirect workspaces.

Sub TransactionsX()

    Dim wrkJet As Workspace
    Dim wrkODBC As Workspace
    Dim dbsNorthwind As Database
    Dim conPubs As Connection
    Dim rstTemp As Recordset

    ' Open Microsoft Jet and ODBCDirect workspaces, a Microsoft
    ' Jet database, and an ODBCDirect connection.
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
    Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
    Set conPubs = wrkODBC.OpenConnection("", , , _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

    ' Open two different Recordset objects and display the
    ' Transactions property of each.

    Debug.Print "Opening Microsoft Jet table-type " & _
        "recordset..."
    Set rstTemp = dbsNorthwind.OpenRecordset( _
        "Employees", dbOpenTable)
    Debug.Print "    Transactions = " & rstTemp.Transactions

    Debug.Print "Opening forward-only-type " & _
        "recordset where the source is an SQL statement..."
    Set rstTemp = dbsNorthwind.OpenRecordset( _
        "SELECT * FROM Employees", dbOpenForwardOnly)
    Debug.Print "    Transactions = " & rstTemp.Transactions

    ' Display Transactions property of a Connection object in
    ' an ODBCDirect workspace.
    Debug.Print "Testing Transaction property of " & _
        "an ODBC connection..."
    Debug.Print "    Transactions = " & conPubs.Transactions

    rstTemp.Close
    dbsNorthwind.Close
    conPubs.Close
    wrkJet.Close
    wrkODBC.Close

End Sub