Selecting Deferred-Update or Immediate-Update
The default lock type in ADO is read-only. This can be changed by specifying the lock type parameter on the recordset’s Open call and affects the method used to write the changes to the recordset.
To update the recordset, change the locktype to use either immediate-update mode, single row deferred-update mode, or multi-row deferred-update mode.
Immediate-Update Mode
OLE DB providers prior to Pervasive.SQL V8 did not support adLockPessimistic for the lock type. If no lock type is specified, the Update method is unnecessary and updates are written to the data store on a field-by-field basis. This is inefficient and should only be used when other types have been proven to be unacceptable for a particular application.
Deferred-Update Modes
There are two deferred-update modes: single-row and multi-row:
Single Row Deferred Update Mode
If adLockOptimistic is used for the lock type, then the Update method should be used for writing changes, and the code should be written to deal with one record at a time. Any operation which causes ADO to act on another row in the recordset or causes a refresh of the current row will trigger an implicit ADO Update call. However, this is much more efficient than immediate-update mode. Here’s an example of opening a recordset using immediate-update mode:
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockOptimistic, adCmdTableDirect
Multi-row Deferred Update Mode
If adLockBatchOptimistic is used for the lock type, then the UpdateBatch method should be used for writing changes, and the code can be written to deal with multiple record changes at once.
This is the best lock type in terms of performance, but it requires that the application design allow ADO to cache and update multiple rows at a time. This may not always be advisable in a multi-user, high-throughput application. Here is an example of opening a recordset using deferred-update mode:
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockBatchOptimistic, adCmdTableDirect