Cursors: Viewing a Recordset

Cursors present a logical view of a particular recordset. Once the records have been selected for us from our data source by opening our Recordset object, we must decide on how we would like them presented. This is done through a cursor. In ADO, there are four types of cursors:

  • Dynamic cursor

  • Keyset cursor

  • Static cursor

  • Forward-only cursor

In the following sections, the different cursor types are explained and an example at the end displays the various functions of each. To prepare your Recordset object to open with a particular cursor, use the CursorType property. The CursorType property is both read- and write-enabled while the Recordset object is closed, but once it is opened, the CursorType property becomes read-only.

Not all providers support all cursor types. When the data provider cannot provide you with the cursor that you have specified because prerequisites could not be met, the data provider may automatically assign a different cursor type. When this occurs, you can read the CursorType property to see the kind of cursor that was actually used when opening the recordset.

Dynamic Cursor

The first type of cursor is a dynamic cursor. A dynamic cursor allows you to move freely throughout your recordset, without restrictions, except when your provider does not support bookmarks -- in this case, you cannot use bookmarks with the Dynamic cursor (see Section 5.3.5 later in this chapter for more information).

“Moving freely through the recordset” means ...

Get ADO: ActiveX Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.