adCmdTableDirect1
|
|
For
information about using adLockBatchOptimistic, see Sample Code for Using adLockBatchOptimistic.
|
|
1If you set the CommandType property to a value other than adCmdTableDirect, the LockType property might revert to adLockReadOnly. Because the provider is not guaranteed to honor the requested lock type, you should always check the value of LockType after the recordset is opened. |
' obConnection is an open Connection object. Dim obRecordset As New ADODB.Recordset ' Set the ActiveConnection, CursorType, and LockType here instead of on the Open method. obRecordset.ActiveConnection = obConnection obRecordset.CursorType = adOpenStatic obRecordset.LockType = adLockBatchOptimistic ' Set the maximum number of rows for batch update. obRecordset.Properties("Maximum Open Rows") = 1000 ' Set exclusive member-level lock. All other users get read-only access. obRecordset.Properties("SAS Optimistic Locking") = False obRecordset.Open "mydata.finance", , , , adCmdTableDirect ' Update every row, setting the BALANCE column of each row to 0. While Not obRecordset.EOF obRecordset!BALANCE = 0 obRecordset.MoveNext Wend obRecordset.UpdateBatch
False
.