DefaultCursorDriver Property

Applies To

Workspace object.

Description

Sets or returns the type of cursor driver used on the connection created by the OpenConnection or OpenDatabase methods (ODBCDirect workspaces only).

Settings And Return Values

The setting or return value is a Long that can be set to one of the following constants.

Constant

Description

dbUseDefaultCursor

(Default) Uses server-side cursors if the server supports them; otherwise use the ODBC Cursor Library.

dbUseODBCCursor

Always uses the ODBC Cursor Library. This option provides better performance for small result sets, but degrades quickly for larger result sets.

dbUseServerCursor

Always uses server-side cursors. For most large operations this option provides better performance, but might cause more network traffic.

dbUseClientBatchCursor

Always uses the client batch cursor library. This option is required for batch updates.

dbUseNoCursor

Opens all cursors (that is, Recordset objects) as forward-only type, read-only, with a rowset size of 1. Also known as "cursorless queries."


Remarks

This property setting only affects connections established after the property has been set. Changing the DefaultCursorDriver property has no effect on existing connections.

Example

This example uses the RecordStatus and DefaultCursorDriver properties to show how changes to a local Recordset are tracked during batch updating. The RecordStatusOutput function is required for this procedure to run.

Sub RecordStatusX()

    Dim wrkMain As Workspace
    Dim conMain As Connection
    Dim rstTemp As Recordset
    Set wrkMain = CreateWorkspace("ODBCWorkspace", _
        "admin", "", dbUseODBC)
    ' This DefaultCursorDriver setting is required for
    ' batch updating.
    wrkMain.DefaultCursorDriver = dbUseClientBatchCursor

    Set conMain = wrkMain.OpenConnection("Publishers", _
        dbDriverNoPrompt, False, _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")
    ' The following locking argument is required for
    ' batch updating.
    Set rstTemp = conMain.OpenRecordset( _
        "SELECT * FROM authors", dbOpenDynaset, 0, _
        dbOptimisticBatch)

    With rstTemp
        .MoveFirst
        Debug.Print "Original record: " & !au_lname
        Debug.Print , RecordStatusOutput2(.RecordStatus)

        .Edit
        !au_lname = "Bowen"
        .Update
        Debug.Print "Edited record: " & !au_lname
        Debug.Print , RecordStatusOutput2(.RecordStatus)

        .AddNew
        !au_lname = "NewName"
        .Update
        Debug.Print "New record: " & !au_lname
        Debug.Print , RecordStatusOutput2(.RecordStatus)

        .Delete
        Debug.Print "Deleted record: " & !au_lname
        Debug.Print , RecordStatusOutput2(.RecordStatus)

        ' Close the local recordset without updating the
        ' data on the server.
        .Close
    End With

    conMain.Close
    wrkMain.Close

End Sub
Function RecordStatusOutput(lngTemp As Long) As String

    Dim strTemp As String

    strTemp = ""

    ' Construct an output string based on the RecordStatus
    ' value.
If lngTemp = dbRecordUnmodified Then _
        strTemp = "[dbRecordUnmodified]"
    If lngTemp = dbRecordModified Then _
        strTemp = "[dbRecordModified]"
    If lngTemp = dbRecordNew Then _
        strTemp = "[dbRecordNew]"
    If lngTemp = dbRecordDeleted Then _
        strTemp = "[dbRecordDeleted]"
    If lngTemp = dbRecordDBDeleted Then _
        strTemp = "[dbRecordDBDeleted]"

    RecordStatusOutput = strTemp

End Function