The open complete syntax in the recordset is
Copy Code code as follows:
Secordset.open source,activeconnection,cursortype,locktype,options
For example: Rs.Open sql,conn,1,3
CursorType is
adOpenForwardOnly 0 The default cursor type, which opens forward cursors and moves forward only in the recordset.
adOpenKeyset 1 opens a keyset-type cursor that can be moved forward or backward in the recordset. If another user modifies or deletes a record, the recordset reflects the change. However, if another user adds a new record, the new record does not appear in the recordset.
adOpenDynamic 2 opens a dynamic cursor that can be moved forward or backward in the recordset. Any changes in the records resulting from other notes will be reflected in the recordset.
adOpenStatic 3 Opens a static cursor that can be moved forward or backward in the recordset. However, static cursors do not reflect record changes caused by other users.
LockType is
adLockReadOnly 1 Read-only locks, specifying that records in the recordset cannot be modified.
Adlockprssimistic 2 protected locking, which is locked immediately when editing a record.
adLockOptimistic 3 Open locks, specifying that records can be locked only when the Update () method of the recordset is invoked.
adLockBatchOptimistic 4 Open Batch locks, specifying that records can only be updated in batches.
two of the most common methods:
Rs.Open sql,conn,1,1 ' reads when displaying data, read only
Rs.Open sql,conn,1,3 ' when updating or inserting data, reading and writing
The following are the supplements of 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 connect to the command object through the Source property. The source parameter can be a command object name, a section of SQL command, a specified data table name, or a stored Procedure. If this argument is omitted, the system takes the source property of the Recordset object.
ActiveConnection
The Recordset object can connect connection objects by ActiveConnection properties. The ActiveConnection can be a connection object or a string parameter containing the database connection information (ConnectionString).
CursorType
The CursorType parameter of the Recordset object Open method indicates what cursor type will start the data, including adOpenForwardOnly, adOpenKeyset, adOpenDynamic, and adOpenStatic. It is described as follows:
Constant |
Constant value |
Description
|
adOpenForwardOnly |
0 default values |
Start a cursor that can only be moved forward (Forward only) |
adOpenKeyset |
1 |
Launches a keyset type of cursor |
adOpenDynamic |
2 |
Start a cursor of the dynamic type |
adOpenStatic |
3 |
Start a static type of cursor |
These cursor types will directly affect all properties and methods of the Recordset object, and the following list illustrates the differences between them.
Recordset Properties |
adOpenForwardOnly |
adOpenKeyset |
adOpenDynamic |
adOpenStatic |
AbsolutePage |
does not support |
does not support |
can read and write |
can read and write |
AbsolutePosition |
does not support |
does not support |
can read and write |
can read and write |
ActiveConnection |
can read and write |
can read and write |
can read and write |
can read and write |
BOF |
Read-only |
Read-only |
Read-only |
Read-only |
Bookmark |
does not support |
does not support |
can read and write |
can read and write |
CacheSize |
can read and write |
can read and write |
can read and write |
can read and write |
CursorLocation |
can read and write |
can read and write |
can read and write |
can read and write |
CursorType |
can read and write |
can read and write |
can read and write |
can read and write |
EditMode |
Read-only |
Read-only |
Read-only |
Read-only |
Eof |
Read-only |
Read-only |
Read-only |
Read-only |
Filter |
can read and write |
can read and write |
can read and write |
can read and write |
LockType |
can read and write |
can read and write |
can read and write |
can read and write |
MarshalOptions |
can read and write |
can read and write |
can read and write |
can read and write |
MaxRecords |
can read and write |
can read and write |
can read and write |
can read and write |
PageCount |
does not support |
does not support |
Read-only |
Read-only |
PageSize |
can read and write |
can read and write |
can read and write |
can read and write |
RecordCount |
does not support |
does not support |
Read-only |
Read-only |
Source |
can read and write |
can read and write |
can read and write |
can read and write |
State |
Read-only |
Read-only |
Read-only |
Read-only |
Status |
Read-only |
Read-only |
Read-only |
Read-only |
AddNew |
Support |
Support |
Support |
Support |
CancelBatch |
Support |
Support |
Support |
Support |
CancelUpdate |
Support |
Support |
Support |
Support |
Clone |
does not support |
does not support |
does not support |
does not support |
Close |
Support |
Support |
Support |
Support |
Delete |
Support |
Support |
Support |
Support |
GetRows |
Support |
Support |
Support |
Support |
Move |
does not support |
Support |
Support |
Support |
MoveFirst |
Support |
Support |
Support |
Support |
MoveLast |
does not support |
Support |
Support |
Support |
MoveNext |
Support |
Support |
Support |
Support |
MovePrevious |
does not support |
Support |
Support |
Support |
NextRecordset |
Support |
Support |
Support |
Support |
Open |
Support |
Support |
Support |
Support |
Requery |
Support |
Support |
Support |
Support |
Resync |
does not support |
does not support |
Support |
Support |
Supports |
Support |
Support |
Support |
Support |
Update |
Support |
Support |
Support |
Support |
UpdateBatch |
Support |
Support |
Support |
Support |
Where the NextRecordset method does not apply to Microsoft Access databases.
LockType
The LockType parameter of the Recordset object's Open method represents the lock type to take, and if this argument is omitted, then the system takes the LockType property of the Recordset object as the preset value. The LockType parameters include adLockReadOnly, adlockprssimistic, adLockOptimistic, and adLockBatchOptimistic, as described below:
Constant |
Constant value |
Description
|
adLockReadOnly |
1 Default values |
The Recordset object starts as read-only and cannot run AddNew, Update, and Delete methods |
Adlockprssimistic |
2 |
When the data source is being updated, the system temporarily locks the actions of other users to maintain data consistency |
adLockOptimistic |
3 |
When the data source is being updated, the system does not lock other users ' actions, other users can add, delete, and change the operation of the data |
adLockBatchOptimistic |
4 |
When the data source is being updated, other users must change the CursorLocation property to Adudeclientbatch to add, delete, and modify the data |
The above is the relevant information, the need for friends can refer to