In a Microsoft Jet workspace, if you provide a syntactically correct SQL statement and have the appropriate permissions, the
Execute method won't fail — even if not a single row can be modified or deleted. Therefore, always use the
dbFailOnError option when using the
Execute method to run an update or delete query. This option generates a run-time error and rolls back all successful changes if any of the records affected are locked and can't be updated or deleted.
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.