The complete syntax of open in RecordSet is
The code copy is as follows:
SecordSet.OpenSource,ActiveConnection,CursorType,LockType,Options
For example: rs.opensql,conn,1,3
CursorType is
adOpenForwardOnly0 has the default cursor type, which can only be moved forward in the record set to open the forward cursor.
adOpenKeyset1 opens a cursor of keyset type, which can be moved forward or backward in the record set. If other users modify or delete a record, the record set will reflect this change. However, if other users add a new record, the new record will not appear in the record set.
AdOpenDynamic2 opens a dynamic cursor that can move forward or backward in the record set. Any changes in the record caused by other records will be reflected in the record set.
adOpenStatic3 opens a static cursor, which can move forward or backward in the record set. However, the static cursor will not reflect the record changes caused by other users.
LockType is
adLockReadOnly1 read-only lock, specifying that records in the record set cannot be modified.
adLockPrssimistic2 protected locking means locking a record immediately when editing it.
adLockOptimistic3 open locking, specifies that records can only be locked when the Update() method of the record set is called.
adLockBatchOptimistic4 open batch locking, specifying records can only be updated in batches.
The two most commonly used methods:
rs.opensql,conn,1,1' is used to read and only read
rs.opensql,conn,1,3' is used to update or insert data, read and write
The following are supplements from other netizens
recordset.Open Source,ActiveConnection,CursorType,LockType,Options
Can be written as:
rs.open SQL statement, conn object, 3 (cursor type), 2 (locking method)
Source
The Recordset object can be connected to the Command object through the Source property. The Source parameter can be a Command object name, a SQL command, a specified data table name, or a Stored Procedure. If this parameter is omitted, the system uses the Source property of the Recordset object.
ActiveConnection
The Recordset object can be connected to the Connection object through the ActiveConnection property. The ActiveConnection here can be a Connection object or a string parameter containing database connection information (ConnectionString).
CursorType
The CursorType parameter of the Open method of the Recordset object indicates what cursor type to start the data, including adOpenForwardOnly, adOpenKeyset, adOpenDynamic and adOpenStatic, which are described as follows: