kisijo
Aug 15th, 2000, 01:50 AM
I am using VB and ADO and have a SQL 7.0 database. I need to lock a record when ADO is in Edit mode so that no other users of the database can edit the same record. If the user puts the record in edit mode and leaves it like this for 1 hour the record must still be locked from other users on different PC's
Has anyone any ideas?
Paul Warren
Aug 15th, 2000, 03:12 AM
When creating a recordset object set the LockType property to one of the following values ( taken from MSDN ) :
Constant Description
adLockReadOnly Default. Read-only—you cannot alter the data.
adLockPessimistic Pessimistic locking, record by record—the provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately upon editing.
adLockOptimistic Optimistic locking, record by record—the provider uses optimistic locking, locking records only when you call the Update method.
adLockBatchOptimistic Optimistic batch updates—required for batch update mode as opposed to immediate update mode.
Set the LockType property before opening a Recordset to specify what type of locking the provider should use when opening it. Read the property to return the type of locking in use on an open Recordset object. The LockType property is read/write when the Recordset is closed and read-only when it is open.
Providers may not support all lock types. If a provider cannot support the requested LockType setting, it will substitute another type of locking. To determine the actual locking functionality available in a Recordset object, use the Supports method with adUpdate and adUpdateBatch.
The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient. If an unsupported value is set, then no error will result; the closest supported LockType will be used instead.
Remote Data Service Usage When used on a client-side (ADOR) Recordset object, the LockType property can only be set to adLockOptimisticBatch.
Hope this helps you decide.