Snapshot-Type Recordset Example (VC++)

This example creates a new snapshot-type Recordset object and opens it, appending it to the Recordsets collection in the default database. It then finds a record and prints it.

CdbDBEngine      dbeng;
CdbDatabase      db;
CdbRecordset   rstTitles;

// Open the database.
db = dbeng.OpenDatabase(_T("Biblio.mdb"));

// Open a recordset on Titles table.
rstTitles = db.OpenRecordset("Titles", dbOpenSnapshot);
if (rstTitles.GetRecordCount() > 0)
   {
   rstTitles.FindFirst("Title Like '*VBSQL*'");  // Any title on VBSQL
   while (rstTitles.GetNoMatch() == TRUE)
      {
      printf("%s\n", rstTitles.Fields[_T("Title")]);
      rstTitles.FindNext(_T("Title Like '*VBSQL*'"));
      }
   }
else
   {
   printf("No such title\n");
   }
      
db.Close();