The CursorType property on a Recordset object indicates the type of the cursor engine. This property sets or returns a Long value representing a CursorTypeEnum.
oldType = connection.CursorType
connection.CursorType = newType
The CursorType property is used to set or return the type of the cursor that the provider should use when opening the Recordset. This property can be one of the following enumerated values for CursorTypeEnum:
Enumeration | Value | Description |
---|---|---|
adOpenUnspecified | -1 | This indicates an unspecified value for the CursorType (not supported by the OLE DB Provider for AS/400 and VSAM). |
adOpenForwardOnly | 0 | Specifying this value opens a forward-only-type cursor. |
adOpenKeyset | 1 | Specifying this value opens a keyset-type cursor (not supported by the OLE DB Provider for AS/400 and VSAM). |
adOpenDynamic | 2 | Specifying this value opens a dynamic-type cursor, the only CursorType supported by the OLE DB Provider for AS/400 and VSAM. Additions, changes, and deletions by other users are visible, and all types of movement through the recordset are allowed, except for bookmarks if the provider does not support them. |
adOpenStatic | 3 | Specifying this value opens a static-type cursor (not supported by the OLE DB Provider for AS/400 and VSAM). |
Note that the Open method on a Recordset object defaults this property to adOpenForwardOnly.
This property setting only affects connections established after the property has been set. Changing the CursorType property has no effect on existing connections. The CursorType property is read/write when the Recordset is closed and read-only when it is open.
If a provider does not support the requested cursor type, the provider may return another cursor type. The CursorType property will change to match the actual cursor type in use when the Recordset object is open. To verify specific functionality of the returned cursor, use the Supports method. When using the OLE DB Provider for AS/400 and VSAM, the Supports method returns adMovePrevious as true with CursorType set to adOpenDynamic. After you close the Recordset, the CursorType property reverts to its original setting.