比如新增记录,或修改记录时,如何锁定这条记录,使其只能一个人进行操作,避免多人同时执行操作。
---------------------------------------------------------------
这个数据库应该会自动锁定的
---------------------------------------------------------------
rs.open conn, sql, 1, 1
----------
Open
This method opens a cursor. The Open method is read-only by default.
Syntax
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
Parameters
Source
Required. Variant that evaluates to a table name or an SQL statement.
ActiveConnection
Optional. Zero-length string ("") that signifies the H/PC object store and is the only available option in ADOCE 1.0.
CursorType
Optional. Determines what movement through the recordset is enabled and how updates to the underlying database are reflected in the Recordset object. It is one of the values described in the following table. Constant Value Description
adOpenForwardOnly 0 Forward-only cursor. Identical to a static cursor except that you can only scroll forward through records. In the current Windows CE-based model, this cursor type does not improve performance. For compatibility with ADO for the desktop computer, however, it remains the default.
adOpenKeyset 1 Keyset cursor. Additions, changes, and deletions by other users are not visible. All types of movement through the recordset is enabled.
Using other values results in a LockType of 1 (adOpenKeyset). Dynamic-type and static-type cursors are not available in ADOCE.
LockType
Optional. Determines what type of locking, or concurrency, the provider should use when opening the Recordset. It is one of the values described in the following table. Constant Value Description
adLockReadOnly 1 Default — you cannot add, delete, or change records.
adLockOptimistic 3 You can add, delete, and change records.
---------------------------------------------------------------
看看数据库的事务和锁,一般分为乐观锁和悲观锁。
一般我们在操作时都上悲观锁。避免用户读到未提交数据。所以你就只管编程,不用管他是怎么锁的。没问题的……