Modifying the Default Behavior of Transaction Processing
Before you learn how to implement transaction processing, take a look at what you can do to modify the default behavior of the transaction processing built in to Access 2003. Three registry settings affect implicit transactions in Access 2003:ImplicitCommitSync, ExclusiveAsnycDelay, and SharedAsyncDelay. These keys are located in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Jet 4.0 registry folder.TIPYou can access the Windows registry using the RegEdit utility. To use RegEdit, select the Run option from the Start menu and then type RegEdit .The ImplicitCommitSync setting determines whether the system waits for a commit to finish before proceeding with application processing. The default is No. This means that the system will proceed without waiting for the commit to finish. You generally won't want to change this setting; using No dramatically improves performance. The danger of accepting the value of No is that you will increase the amount of time during which the data is vulnerable. Before the data is flushed to disk, the user might turn off the machine, compromising the integrity of the data.The ExclusiveAsyncDelay setting specifies the maximum number of milliseconds that elapse before Jet commits an implicit transaction when a database is opened for exclusive use. The default value for this setting is 2000 milliseconds. This setting does not in any way affect databases that are open for shared use.The SharedAsyncDelay setting is similar to the ExclusiveAsyncDelay setting. It determines the maximum number of milliseconds that elapse before Jet commits an implicit transaction when a database is opened for shared use. The default value for this setting is 50. The higher this value, the greater the performance benefits reaped from implicit transactions, but also the higher the chances that concurrency problems will result. These concurrency issues are discussed in detail in Alison Balter's Mastering Access 2002 Enterprise Development .In addition to the settings that affect implicit transaction processing in Access 2003, an additional registry setting affects explicit transaction processing. The UserCommitSync setting controls whether explicit transactions are completed synchronously or asynchronously. With the default setting of Yes, control doesn't return from a CommitTrans statement until the transactions are actually written to disk, resulting in synchronous transactions. When this value is changed to No, a series of changes is queued, and control returns before the changes are complete.You can modify the values of these registry settings and other Jet settings by using Regedit.exe (the Registry Editor) for Windows NT, Windows 2000, and Windows 2003. Changes to this section of the registry affect all applications that use the Jet 4.0 Engine. If you want to affect only your application, you can export the Microsoft Jet portion of the registry tree and import it into your application's registry tree. You then can customize the registry settings for your application. To force your application to load the appropriate registry tree, you must set the INIPath property of the DBEngine object.A much simpler approach is to set properties of the ADO Connection object; you can specify new settings at runtime for all the previously mentioned registry entries as well as for additional entries. A further advantage of this approach is that it will modify (temporarily) registry entries for any machine under which your application runs. Any values you change at runtime temporarily override the registry values that are set, enabling you to easily control and maintain specific settings for each application. This code illustrates how you modify the ExclusiveAsyncDelay and SharedAsyncDelay settings using properties of the Connection object:Sub ChangeOptions()
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
cnn.Properties("JET OLEDB:Exclusive Async Delay") = 1000
cnn.Properties("JET OLEDB:Shared Async Delay") = 50
End Sub