共用方式為


Selecting and Manipulating Records

OverviewHow Do IFAQSampleODBC Driver List

Normally when you select records from a data source using an SQL SELECT statement, you get a “result set” — 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 . 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. Either ClassWizard or AppWizard creates a class with a connection to a specific data source. The wizards write the member function of class CRecordset to return the table name. For more information on using the wizards to create recordset classes, see the articles Overview: Creating a Program That Supports a Database and ClassWizard: Database Support.

Using a 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 updatable).

  • 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 the article Recordset (ODBC).