DAO Tabledef

OverviewHow Do IFAQSampleODBC Driver List

This article describes "tabledefs" and the key features of the MFC class. Additional articles explain how to use tabledefs. For task-oriented information, see the article DAO Tabledef: Using Tabledefs. For an understanding of the DAO tabledef object underlying each MFC CDaoTableDef object, see the topic "TableDef Object" in DAO Help.

Topics covered include:

  • Tabledef: definition

  • Tabledef uses

  • Tabledefs and DAO collections

  • Further reading about tabledefs

Tabledef: Definition

A DAO tabledef, represented in MFC by a object, is an object that defines the structure of a base table or an attached table.

A base table is a table in a Microsoft Jet (.MDB) database. You can manipulate the structure of a base table using DAO objects or data definition language (DDL) SQL statements, and you can use recordsets and action queries to modify data in a base table.

An attached table is a table in another database linked to a Microsoft Jet (.MDB) database. Data for attached tables remains in the external database where it may be manipulated by other applications. You can't use the table-type recordset with attached tables, and you can’t modify the schema of attached tables, but you can use dynaset-type and snapshot-type recordsets with attached tables.

Tabledef Uses

The main use for tabledef objects is to manipulate the structure of a table. You can:

  • Base a recordset on a tabledef. The recordset is a table-type recordset. See in the Class Library Reference.

  • Examine the structure of local base tables, attached tables, and external tables. The structure of a table includes its fields and indexes.

  • Add or delete fields and indexes in local base tables and external tables that you open directly rather than attaching.

  • Set the connection information and the name of an attached table and refresh the link to an attached table.

  • Determine whether the data in table fields is editable.

  • Get or set a table's validation conditions.

You can use tables as the basis for opening recordsets in two ways. You can:

  • Open a recordset based on a pointer.

  • Create a table-type recordset based on the table, usually by using AppWizard or ClassWizard.

For a complete discussion of what you can do with tabledefs, see the topic "TableDef Object" in DAO Help.

Tabledefs and DAO Collections

Each DAO database object maintains a TableDefs collection — a collection of all saved table definitions in the database. The collection contains one tabledef for each table in the database. Each tabledef object maintains two collections of its own:

  • Fields   All of the fields in the table definition — one for each field in the underlying table.

  • Indexes   All of the indexes defined for the table.

MFC objects don't store a representation of a DAO collection. Instead, MFC accesses the collection through the underlying DAO object. For more information, see the article DAO Collections.

MFC also doesn't provide a C++ class to represent every DAO object. In particular, there is no MFC field object or index object. You work with a tabledef's fields and indexes through member functions of class .

Further Reading About Tabledefs

For more information about tabledefs in MFC, see the following additional articles (in the order listed here):

General Tabledef Article

Tables in External Data Sources

See Also   DAO: Where Is..., DAO Querydef, DAO Recordset, DAO Database