Data Access and Transactions |
The server-side Recordset supports four types of record locking (also called concurrency), as shown in Table 7.5.
Table 7.5 ADO Cursor Lock Types
LockType | Meaning |
adLockReadOnly | The database doesn’t lock records, since you are only accessing them in readonly state. This is the default concurrency. |
adLockPessimistic | The database locks the records being changed as soon as editing begins. The records are unlocked when all changes are complete. No two users can access the same records at the same time. |
adLockOptimistic | The database locks the records being changed only when the changes are committed. Two users can access the same record at the same time, and the database must be able to reconcile (or simply reject) conflicts. |
adLockBatchOptimistic | This mode is required for batch updates using client cursors, and is similar to optimistic concurrency. |
Note If you fetch more than a single record into the record cache, you should use optimistic concurrency. Doing so allows the server to forgo locks on the database until they are needed, thus freeing resources. However, if there is high contention for the resource, pessimistic concurrency may be preferred. It is easier to reject a request to access a database and have the server try again than it is to reconcile data that is rapidly becoming out-of-date in a record cache.