Lock Mode Property

ADO and SQL Server

ADO and SQL Server

Lock Mode Property

The Lock Mode property specifies the level of locking performed by the recordset.

Applies To
Command Object
Syntax

object.Properties("Lock Mode") [= value]

Parts

object

Expression that evaluates to an object in the Applies To list.

value

Integer that specifies the level of locking as described in Settings.

Settings
Constant Description
DBPROPVAL_LM_NONE The provider is not required to lock rows at any time to ensure successful updates. Updates may fail when sent to the server for reasons of concurrency (for example, if someone else has updated the row).
DBPROPVAL_LM_SINGLEROW The provider uses the minimum level of locking necessary to ensure that changes successfully written to a single row returned by the most recent fetch will not fail due to a concurrency violation. Therefore, using deferred update mode will not fail due to a concurrency violation. This may mean that the provider takes a lock on the row when the Update method is first called on the row, but the provider may lock the row as early as when it is read to guarantee that operations on the row, such as updates, will succeed. The implications of DBPROPVAL_LM_SINGLEROW, and the Lock Mode property in general, are the same in both immediate and deferred update modes.

Data Type

adInteger

Modifiable

Read/write

OLE DB Property

DBPROP_LOCKMODE

Remarks

Lock mode and isolation level are closely related but distinct. An application's isolation level specifies the isolation of that application from changes made by other users to the underlying data. Lock mode defines when underlying data is locked to ensure that updates succeed. The provider may use locking to enforce higher levels of isolation, in which case a higher level of locking may occur than is required to enforce the specified lock mode. The Lock Mode property specifies the minimum level of locking.