Example: Rs. Open sql,conn,0,2,1
CursorType = 0, the default value, opens only forward-type cursors.
LockType = 2, open lock
Options = 1, which instructs ADO to generate SQL queries
The specific syntax is as follows:
Grammar
Recordset. Open Source, ActiveConnection, CursorType, LockType, Options
Parameters
Source Optional, Variant, calculates the Command object's variable name, SQL statement, table name, stored procedure call, or persistent Recordset file name.
ActiveConnection is optional. Variant type, which evaluates the valid Connection object variable name, or string that contains the ConnectionString parameter.
CursorType Optional, CursorTypeEnum value that determines the type of cursor the provider should use when opening the Recordset. Can be one of the following constants (see the CursorType property for a definition of these settings).
Constant description
adOpenForwardOnly (default) opens only forward-type cursors.
adOpenKeyset Open the keyset type cursor.
adOpenDynamic open a dynamic type cursor.
adOpenStatic open a static type cursor.
LockType is optional. Determines the LockTypeEnum value of the lock (concurrency) type that the provider should use when opening the Recordset, which can be one of the following constants (see the LockType property for more information).
Constant description
adLockReadOnly (default) read-only-cannot change data.
adLockPessimistic pessimistic locking (one-by-one)-the provider completes the work required to ensure that records are successfully edited, usually by locking the records of the data source as soon as they are edited.
adLockOptimistic Open Lock (PER)-the provider uses an open lock to lock records only when the Update method is called.
adLockBatchOptimistic Open Batch Update-for batch update mode (as opposed to immediate update mode).
Options optional, long integer value that indicates how the provider calculates the Source parameter if it represents a Command object, or recovers the recordset from a file that previously saved the recordset. Can be one of the following constants (see the CommandType property for a detailed description of the first five constants in the list).
Constant description
adCmdText indicates that the provider should calculate Source as the text definition of the command.
adCmdTable instructs ADO to generate SQL queries to return all rows from the table named by Source.
adCmdTableDirect instructs the provider to change all rows returned from the table named by Source.
adCmdStoredProc indicates that the provider should treat Source as a stored procedure.
adCmdUnknown indicates that the command type in the Source parameter is unknown.
Adcommandfile indicates that a persisted (saved) Recordset should be recovered from a file named from Source.
The adexecuteasync indicates that the Source should be executed asynchronously.
Adfetchasync indicates that all remaining rows should be fetched asynchronously after extracting the initial quantity specified in the CacheSize property.
Rs. Open sql,conn,0,2,1