This article is the fourth of a series on how to retrieve and update information stored in databases. In this section, we look into the ADO methods to let users add, edit, and delete information in a data set.
Recall that the behavior of a Recordset is affected by how its CURSOR and LOCK properties are configured. A Recordset by default opens with a forward-only CursorType, and its LockType set to read-only.
To be able to update a Recordset, you can use any of the CursorTypes, but its LockType property must be set to other than the default. You can do this either before opening the Recordset object, for example
recordset.CursorType=1
recordset.LockType=3
or can be passed as arguments in the recordSet.Open method call.
recordset.Open "tableName", connectionObj, 1, 3, 2
Alternatively, if you use the ADO constants include file, you can use
recordset.Open "tableName", connectionObj,
adOpenKeyset, adLockOptimistic, adCmdTable
For these exercises, we shall be using a Recordset that is opened with either a keyset or dynamic cursor and employs optimistic locking.