Share via


How to: Control Transactions Manually

If you want to control transactions manually, you can set the Transactions property to 2, or DB_TRANSMANUAL. With manual transaction handling, Visual FoxPro automatically begins a transaction for you when you issue the first data-writing SQL statement, but you must submit the Visual FoxPro SQLCOMMIT( ) or SQLROLLBACK( ) functions to end the transaction. For the CursorAdapter object, you can set the UseTransactions property to false (.F.) and the CursorAdapter does not use transactions to send Insert, Update, or Delete commands.

To use manual transaction mode

  1. Use the DBSETPROP( ) Function to set the Transactions property on the connection to 2 or DB_TRANSMANUAL.

    -or-

  2. Use the SQLSETPROP( ) Function to set the Transactions property on the active connection to 2 or DB_TRANSMANUAL.

Transaction processing is handled manually through SQLCOMMIT( ) Function SQLCOMMIT( ) Functionand SQLROLLBACK( ) Function.

After committing or rolling back the prior transaction, Visual FoxPro automatically begins a new transaction when you issue the next data-writing SQL statement. For more information about transactions, see Programming for Shared Access.

Visual FoxPro supports transactions nested up to five levels for local data. A single level of transaction support is built into SQL pass-through.

If your server supports multiple levels of transactions, you can use SQL pass-through to manage transaction levels explicitly. Explicit transaction management is complex, however, because it can be difficult to control the interaction between the built-in transaction and the timing of remote server transactions. For more information on explicit transaction management, see your ODBC documentation.

See Also

Tasks

How to: Use Automatic Transaction Mode

Concepts

Working with Remote Data Using SQL Pass-Through

Reference

UseTransactions Property

Other Resources

Using SQL Pass-Through Technology

Enhancing Applications Using SQL Pass-Through Technology

Planning Client/Server Applications

Upsizing Visual FoxPro Databases

Creating Views