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, and the current data record can be moved freely.
ADOpenstatic (=3)
It can be read and written, 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, locking the record immediately as long as the editing begins.
ADLockoptimic (=3)
Optimistic locking, the record is not locked until the updated record is submitted using the Update method.
ADLockbatchoptimistic (=4)
Batch optimistic locking allows multiple records to be modified, and records are locked only when the UPDATE BATCH method is called.
When no changes to any records are required, a read-only record set should be used so that the provider does not need to do any detection. For general use, optimistic locking may be the best option, as the record is locked for only a short period of time, and the data is updated during this period. This reduces the utilization of resources.
Data from the provider can be manipulated using the Recordset object. When using ADO, almost all data can be operated on through the Recordset object. All Recordset objects are constructed using records (rows) and fields (columns). Some Recordset methods or properties may be invalid due to different features supported by the provider.
Four different cursor types are defined in ADO:
Dynamic Cursor? Used to view additions, changes, and deletions made by other users, and to use various types of movement in a recordset that does not depend on bookmarks. If supported by the provider, bookmarks can be used.
Keyset cursor? Its behavior is similar to dynamic cursors. The only difference is that it prohibits viewing records added by other users and prohibits accessing records deleted by other users. Data changes made by other users will still be visible. It always supports bookmarks, thus allowing various types of movement in the Recordset.
Static Cursor? Provides a static copy of the record collection to find data or generate reports. It always supports bookmarks, thus allowing various types of movement in the Recordset. Additions, changes, or deletion made by other users will not be visible. This is the only cursor type that is allowed when opening a Client (ADOR) Recordset object.
Forward cursor only? Behavior is like a static cursor except that it only allows forward scrolling in a record. This improves performance when one-way movement in the Recordset is required.
Set the CursorType property to select the cursor type before opening Recordset, or pass the CursorType parameter using the Open method. Some providers do not support all cursor types. Please check the provider's documentation. If no cursor type is specified, ADO will turn on forward cursor only by default.
If the CursorLocation property is set to adUseClient and the Recordset is turned on, the UnderlyingValue property of the Field object is not available in the returned Recordset object. For some providers, such as Microsoft ODBC Provider for OLE DB, along with Microsoft SQL Server, you can independently create a Recordset object based on the previously defined Connection object by passing the connection string using the Open method. ADO still creates the Connection object, but it does not assign the object to the object variable. However, if multiple Recordset objects are opened on the same connection, the Connection object should be created and opened explicitly, thereby assigning the Connection object to the object variable. If the object variable is not used when the Recordset object is opened, ADO will create a new Connection object for each new Recordset even when the same connection string is passed.