Share via


Databases Samples

MFC has two kinds of database classes: those based on Open Database Connectivity (ODBC) and those based on Data Access Objects (DAO).

DAO Database Class Samples

DAOCONT shows how to build an OLE control container that contains data-bound controls. The container provides the controls with data from an Access database via DAO

DAOENROL is a sample that is based on the ENROLL sample, but migrated to the DAO database classes.

DAOTABLE demonstrates using the MFC Data Access Objects (DAO) database classes to create common database objects: databases, tables, queries, fields, and indexes.

DAOVIEW is a moderately sophisticated browser that lets you examine the schema of a database.

ODBC Database Class Samples

DBFETCH demonstrates the use of bulk row fetching and shows how to use the ODBC SQLSetPos API call for updating records.

ENROLL is a database application that illustrates adding, updating, and deleting database records from a student registration database.

The DYNABIND sample illustrates dynamic binding of database columns to a recordset. The techniques demonstrated by DYNABIND are useful for adding a customer site customization capability to a database application.

ODBCINFO shows how to determine various ODBC driver capabilities at run time. ODBCINFO opens a selected ODBC data source and displays information about it in a set of property pages.

MFCROWS shows how to use COleDBRecordView to scroll through a table in a database. It also demonstrates how to use multiple accessors so you can update an Access table that contains an AutoNumber field to be retrieved.

STDREG is a tool for populating the Student Registration database, which is used by the Enroll database, in any format supported by an ODBC driver. As a sample, STDREG illustrates how to dynamically create tables and columns in a database using direct SQL.

The CATALOG sample shows the following:

  • Calling Open Database Connectivity (ODBC) functions directly in general, and the ODBC functions SQLTables and SQLColumns in particular.
  • Displaying all the tables in a selected database and, for each table, a list of the columns and information about each column.
  • A reusable CColumns class that represents the result set of a call to the ODBC function SQLColumns. Each record describes one column of a specified table.

CATALOG2 also lets you browse the schema of a data source, but also uses Windows Common Controls to display the information.

See Also

MFC Samples | Categorical List of MFC Samples