Using Transactions in the Multiuser Environment

You can use Microsoft Jet transactions to group updates in units that can be committed or rolled back as a whole. Because transactions save updates in a temporary file instead of in real tables, they also have useful effects in multiuser environments. The most common use of transactions in multiuser environments is to make sure users don’t see an incomplete view of shared data as it’s being changed.

For example, assume your application is running code that is updating data, and another user is simultaneously running a report on that data. If you don’t wrap your updates in a transaction, the user running the report could receive inconsistent data if some records have been updated by your code, and some have not been. If you wrap your updates in a transaction, however, the other user can’t receive inconsistent data because all records are updated at once.

Try not to keep a transaction open too long. All locks that result from your edits with the transaction are kept in place until the transaction is committed or rolled back. This can diminish the concurrency of your multiuser application.

See Also   For more information on transactions, see “Microsoft Jet Transactions” in Chapter 9, “Working with Records and Fields.”