Dynaset-Type Recordsets

In its simplest form, a dynaset-type Recordset object is a collection of bookmarks that allow each record in a server database table to be uniquely identified. Each bookmark corresponds to one record on the server. Normally, the value of the bookmark corresponds to the primary key value for that record. For example, if you have an Orders table on the server database with a primary key on its OrderID field, then internally to Microsoft Jet, the dynaset contains all the OrderID values corresponding to the records that satisfy the query that was issued.

See Also For information on how these bookmarks are gathered, and in particular when they are gathered, see “Recordset Population” later in this chapter.

Note that if you try to examine the contents of the Bookmark property of a dynaset, it will not contain the value in the primary key field. Exactly what it contains varies with the implementation of the recordset. Although you should never rely on it, the Bookmark property will probably contain the page number in the temporary Microsoft Jet database where the primary key value is stored. The reason the engine does not use primary key field values as bookmark values is that dynasets can be based on a multiple-table join. In such a case, there are several primary key values stored by Microsoft Jet — one for each record in each table involved in the join.

When you access the data in dynaset fields, Microsoft Jet uses the bookmark for the record to issue a query in the following form:

"SELECT field1, field2,... FROM ORDERS WHERE ORDERID=bookmark"

This statement is then sent to the server. (For performance reasons, Microsoft Jet includes up to ten bookmarks in the WHERE clause.) Then, as you request the data, Microsoft Jet calls the ODBC SQLGetData function on a field-by-field basis to return the data from each field.

One of the most important implications of this field-by-field behavior is that data for a field is not retrieved from the server unless that field is explicitly retrieved by your application’s code. For example, only if your code contained a line such as

strNew = rstOrders!Photo

would the Photo field be retrieved from the server. This behavior is of particular interest if the table you are accessing has Long Binary (OLE Object) or Memo fields that contain large amounts of data. If you don’t reference those large fields in your code, Microsoft Jet does not have to retrieve them from the server.

Once you have the bookmarks you need, the most time-consuming part of using a dynaset is retrieving the data. To speed this up, you can tell a Recordset to cache the data that it retrieves and keep it in memory so that if you need it again you can avoid retrieving it from the server again. You can control dynaset caching by using the FillCache method and the CacheStart and CacheSize properties of the Recordset object.

See Also For more information, see “Caching Remote Data” later in this chapter.