Visual Studio 6.0 Do IFAQSample Driver List

A snapshot is a recordset that reflects a static view of the data as it existed at the time the snapshot was created. Once you open the snapshot and move to all the records, the set of records it contains and their values don’t change until you rebuild the snapshot by calling Requery.

Note   This article applies to the MFC ODBC classes. If you’re using the MFC DAO classes instead of the MFC ODBC classes, see for a description of snapshot-type recordsets. Also see the article DAO Recordset: Creating Recordsets.

You can create updatable or read-only snapshots with the database classes. Unlike a dynaset, an updatable snapshot doesn’t reflect changes to record values made by other users, but does reflect updates and deletions made by your program. Records added to a snapshot don’t become visible to the snapshot until you call Requery.

Tip   A snapshot is an ODBC “static cursor.” Static cursors don’t actually get a row of data until you scroll to that record. To ensure that all records are immediately retrieved, you can scroll to the end of your recordset, then scroll to the first record you’re interested in. Note, however, that scrolling to the end entails extra overhead and can lower performance.

Snapshots are most valuable when you need the data to remain fixed during your operations, as when you’re generating a report or performing calculations. Even so, the data source can diverge considerably from your snapshot, so you may want to rebuild it from time to time.

Snapshot support is based on the ODBC Cursor Library, which provides static cursors and positioned updates (needed for updatability) for any Level 1 driver. The cursor library DLL must be loaded in memory for this support. When you construct a CDatabase object and call its OpenEx member function, you must specify the CDatabase::useCursorLib option of the dwOptions parameter. If you call the Open member function, then the cursor library is loaded by default. Note that if you are using dynasets instead of snapshots, you do not want to cause the cursor library to be loaded.

Snapshots are available only if the ODBC Cursor Library was loaded when the CDatabase object was constructed or the ODBC driver you’re using supports static cursors.

Important   For some ODBC drivers, snapshots (static cursors) may not be updatable. Check your driver documentation for cursor types supported and the concurrency types they support. To guarantee updatable snapshots, make sure you load the cursor library into memory when you create a CDatabase object. See the article ODBC: The ODBC Cursor Library.

Note   If you want to use both snapshots and dynasets, you must base them on two different CDatabase objects (two different connections).

For more information about the properties snapshots share with all recordsets, see the article Recordset (ODBC). For more information about ODBC and snapshots, including the ODBC Cursor Library, see the article ODBC.