This method opens a cursor. The Open method is read-only by default.
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
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.
Constant |
Value |
Description |
adLockReadOnly | 1 | Default — you cannot add, delete, or change records. |
adLockOptimistic | 3 | You can add, delete, and change records. |
Using other values results in a LockType of 3 (adLockOptimistic), unless the table itself is read-only. In that case, the LockType is 1 (adLockReadOnly). For compatibility with ADO for the desktop computer, the default LockType is 1 (adLocklReadOnly). Pessimistic and optimistic batch locking are unavailable in ADOCE.
Constant |
Value |
Description |
adCmdText | 1 | Evaluates Source as an SQL statement. |
adCmdTable | 2 | Evaluates Source as a table name from “MSysTables.” |
adCmdStoredProc | 4 | Evaluates Source as a stored procedure from “MSysProcs.” |
adCmdUnknown | 8 | Default — the type of command in the Source property is unknown. |
No Command object exists in ADOCE, so the Source parameter must be a string.
No Connection object exists in ADOCE, and the object store is the only possible connection. The ActiveConnection parameter, if specified, must be a zero-length string ("").
If you know what type of command you are using, setting the Options parameter instructs ADOCE to go directly to the relevant code. If the Options parameter does not match the type of command in the Source parameter, an error occurs when you call the Open method.
When the Open method is called with a non-row returning SQL command such as CREATE TABLE, no recordset is returned and the state of the recordset remains closed.
While ADOCE databases are primarily single-user, other applications can open a recordset on the same database. For each recordset it opens, ADOCE generates a keyset that holds pointers to all the database rows referred to by that recordset. In a multiuser scenario, the keyset may hold pointers to records that have been deleted by other applications after the recordset was initially opened; this is because the keyset is not dynamically updated with changes to the underlying database. Attempting to access those deleted records generates an error. When rows are added to the database by means of the current open recordset, the keyset for that recordset is also updated.
Additionally, in a multiuser scenario, when rows are added to the database by other applications, the keysets for other recordsets referring to that database are not dynamically updated and the rows added by the other application are not visible. Changes by other applications to the rows the keyset knows about are still visible because the pointer to the row remains valid. To generate a new keyset and view additions and deletions by other applications, close the recordset and reopen it. Cloned recordsets share a common keyset.
The following code example sets CursorType and LockType constants for the Open method.
Const adOpenKeyset = 1
Const adLockOptimistic = 3
Dim rstLocked, rstUpdateable
Set rstLocked = CreateObject("adoce.recordset")
Set rstUpdateable = CreateObject("adoce.recordset")
'The default is to open a read-only, forward-only recordset
rstLocked.Open "table1"
'You must specify other parameters to make a recordset updateable
rstUpdateable.Open "table2","", adOpenKeyset, adLockOptimistic