Choosing a Cursor Type

When you open a Recordset object on a non-ODBC data source, you can specify a constant for the type argument of the OpenRecordset method that determines what type of Recordset object is opened. When you open a Recordset object on an ODBC data source, you use this same argument to specify the type of cursor that the Recordset object represents. Each type of cursor corresponds to a type of Recordset object. The following table shows the four constants you can use for the type argument, the type of Recordset object that is created on a non-ODBC data source, and the type of cursor that is created on an ODBC data source.

Constant Recordset type Cursor type
dbOpenDynamic Dynamic-type Dynamic
dbOpenDynaset Dynaset-type Keyset
dbOpenSnapshot Snapshot-type Static
dbOpenForwardOnly Forward-only-type Forward-only scrolling (this is the default)

Note Table-type Recordset objects aren’t supported in ODBCDirect workspaces, so they have no corresponding cursor.

See Also For more information about ODBC cursors, see the Microsoft ODBC 3.0 Software Development Kit and Programmer’s Reference.

The DefaultCursorDriver property of a Workspace object specifies where ODBCDirect creates the cursor — on the client or on the server. You can set the DefaultCursorDriver property to any of the constants listed in the following table.

Constant Description
dbUseODBCCursor Use client-side cursors. Client-side cursors give better performance for small result sets, but degrade quickly for larger result sets.
dbUseServerCursor Use server-side cursors. For most large operations, server-side cursors provide better performance, but may cause more network traffic. Not all ODBC data sources support server-side cursors.
dbUseDefaultCursor Use server-side cursors if the server supports them; otherwise, use client-side cursors.
dbUseClientBatchCursor Use client batch cursors. Required for batch updates.
dbUseNoCursor Open all Recordset objects as forward-only-type, read-only, with a rowset size of 1.

Note As of the time this book was printed, if you set the DefaultCursorDriver property of the workspace to dbUseClientBatchCursor, and then use the Move method on a Recordset object using a value of 2 or more for the rows argument, the cursor is moved forward one more row than expected.