[AccessD] Execute and transaction

Gustav Brock Gustav at cactus.dk
Mon Nov 29 06:01:53 CST 2004


Hi all

If you use the Execute method to run action queries, pay attention to
this from the on-line help:

<snip>

In earlier versions of the Microsoft Jet Database Engine, SQL
statements were automatically embedded in implicit transactions. If part
of a statement executed with dbFailOnError failed, the entire statement
would be rolled back. To improve performance, these implicit
transactions were removed starting with version 3.5. If you are updating
older DAO code, be sure to consider using explicit transactions around
Execute statements.

For best performance in a Microsoft Jet workspace, especially in a
multiuser environment, nest the Execute method inside a transaction. Use
the BeginTrans method on the current Workspace object, then use the
Execute method, and complete the transaction by using the CommitTrans
method on the Workspace. This saves changes on disk and frees any locks
placed while the query is running.

</snip>

I just had to debug a case where an extremely simple update query (one
table, less than 2000 records, updating an indexed field) during testing
ran "just like that" while run from code took more than one minute.
Wrapping it in a transaction cut the duration to one second:

<code snip>

    wks.BeginTrans
      qdf.Execute dbFailOnError
      qdf.Close
    wks.CommitTrans

</code snip>

/gustav



More information about the AccessD mailing list