Selecting and Manipulating Records
Normally when you select records from a data source using a SQL SELECT statement, you get a result set, which is a set of records from a table or a query. With the database classes, you use a recordset object to select and access the result set. This is an object of an application-specific class that you derive from class CRecordset. When you define a recordset class, you specify the data source to associate it with, the table to use, and the columns of the table. The MFC Application Wizard or Add Class (as described in Adding an MFC ODBC Consumer) creates a class with a connection to a specific data source. The wizards write the GetDefaultSQL member function of class CRecordset to return the table name. For more information about using the wizards to create recordset classes, see Database Support, MFC Application Wizard and Adding an MFC ODBC Consumer.
Using a CRecordset object at run time, you can:
Examine the data fields of the current record.
Filter or sort the recordset.
Customize the default SQL SELECT statement.
Scroll through the selected records.
Add, update, or delete records (if both the data source and the recordset are updateable).
Test whether the recordset allows requerying and refresh the recordset's contents.
When you finish using the recordset object, you close and destroy it. For more information about recordsets, see Recordset (ODBC).