I often develop asp, but I don’t know the truth about the detailed statement. I will briefly introduce it here.
Under normal circumstances
Read data using rs.open sql,conn,1,1
Modify data: rs.open sql,conn,1,3
Delete data: directly conn.execute("delete * from new where id=1") and so on.
Rs.Open syntax is as follows: rs.Open Source, ActiveConnection, CursorType, LockType
Source is a sql statement, ActiveConnection is a database connection, CursorType is a cursor, and LockType is a data lock type.
CursorType
Constant description
adOpenForwardOnly (value 0) (default) opens forward-only type cursors.
adOpenKeyset(value 1) Opens the keyset type cursor.
adOpenDynamic(value 2) Opens the dynamic type cursor.
adOpenStatic (value 3) Opens a static typed cursor.
LockType
Constant description
adLockReadOnly (value 1) (default) read-only—cannot change data.
adLockPessimistic(value 2) Conservative locking (by-one) — The provider does the work required to ensure successful editing of records, usually by locking records from the data source immediately when editing.
adLockOptimistic(value 3) Open Lock (by-one) — The provider uses open locking to lock records only when the Update method is called.
adLockBatchOptimistic (value 4) Open Batch Update—Use the batch update mode (as opposed to the update now mode).
CursorType
0 Only forward cursor, only forward browsing records, and does not support pagination, Recordset, BookMark
1 Key set cursor, the modifications made by other users to the record will be reflected in the record set, but other users add or delete records will not be reflected in the record set. Supports pagination, Recordset, BookMark
2 Dynamic cursors have the strongest functions, but also consume the most resources. The modifications, additions or deletions of records by users to records will be reflected in the record set. Support full-featured browsing.
3 Static cursor is just a snapshot of the data. The modifications made by the user to the record, addition or deletion of records will not be reflected in the record set. Supports forward or backward movement
LockType
LockType is the lock type of the record set, and its value is:
1 Lock type, default, read-only, no modification can be made
2 Lock the record immediately when editing, the safest way
3 The record set is locked only when the Update method is called, and other previous operations can still change, insert and delete the current record, etc.
4 Records will not be locked when editing, but are changed, inserted and deleted
rs.open sql,conn,3,2
These two are cursors, and their specific functions are:
RS.OPEN SQL,CONN,A,B
A:
ADOPENFORWARDONLY(=0)
Read-only, and the current data record can only be moved downward
ADOPENKEYSET(=1)
Read-only, the current data record can be moved freely
ADOPENDYNAMIC(=2)
Readable and writeable, the current data record can be moved freely
ADOPENSTATIC(=3)
Readable and writeable, the current data record can be moved freely, and new records can be seen
B:
ADLOCKREADONLY(=1)
The default lock type is read-only, and records cannot be modified.
ADLOCKPESSIMISTIC(=2)
Pessimistic locking, when the record is modified, the data provider will try to lock the record to ensure successful editing of the record. As long as the edit begins, the record is locked immediately.
ADLOCKOPTIMISTIC(=3)
Optimistic locking, the record is not locked until the update record is submitted using the Update method.