VB3 Speed Up Data Access by Using BeginTrans & CommitTransLast reviewed: January 9, 1997Article ID: Q109830 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0
SUMMARYYou can speed up database operations by many times in a Microsoft Access database by using transactions. A transaction starts with a BeginTrans statement and ends with a CommitTrans or Rollback statement. The sample program below is more than 17 times faster when using BeginTrans/CommitTrans. Performance may vary on different computers.
MORE INFORMATIONYou can tune the performance of Visual Basic by using transactions for operations that update data. A transaction is a series of operations that must execute as a whole or not at all. You mark the beginning of a transaction with the BeginTrans statement. You use the Rollback or CommitTrans statement to end a transaction. You can usually increase the record updates per second (throughput) of an application by placing operations that update data within an Access Basic transaction. Because Visual Basic locks data pages used in a transaction until the transaction ends, using transactions will prevent access to those data pages by other users while the transaction is pending. If you use transactions in a multi-user environment, try to find a balance between data throughput and data access. If database operations are not within a transaction, every Update method causes a disk write. Transactions are very fast because they are written to a buffer in memory instead of to disk. CommitTrans writes the changes in the transaction buffer to disk. Robust error trapping is important when using transactions to avoid losing writes if the program gets an error in the middle of a transaction. For more performance tuning tips for data access in Microsoft Visual Basic version 3.0, see the PERFORM.TXT file.
Step-by-Step Example
REFERENCES
|
KBCategory: kbprg kbcode
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |