CdbTableDef Object

See Also   Methods   Properties

A CdbTableDef object represents the stored definition of a base table or a linked table (Microsoft Jet workspaces only).






Remarks

You manipulate a table definition using a CdbTableDef object and its methods and properties. For example, you can:

For base tables, the RecordCount property contains the number of records in the specified database table. For linked tables, the RecordCount property setting is always -1.

To create a new CdbTableDef object, use the CreateTableDef method.

To add a field to a table

  1. Make sure any CdbRecordset objects based on the table are all closed.

  2. Use the CreateField method to create a CdbField object variable and set its properties.

  3. Use the Append method to add the CdbField object to the Fields collection of the CdbTableDef object.

You can delete a CdbField object from a TableDefs collection if it doesn't have any indexes assigned to it, but you will lose the field's data.

To create a table that is ready for new records in a database

  1. Use the CreateTableDef method to create a CdbTableDef object.

  2. Set its properties.

  3. For each field in the table, use the CreateField method to create a CdbField object variable and set its properties.

  4. Use the Append method to add the fields to the Fields collection of the CdbTableDef object.

  5. Use the Append method to add the new CdbTableDef object to the TableDefs collection of the Database object.

A linked table is connected to the database by the SourceTableName and Connect properties of the CdbTableDef object.

To link a table to a database

  1. Use the CreateTableDef method to create a CdbTableDef object.

  2. Set its Connect and SourceTableName properties (and optionally, its Attributes property).

  3. Use the Append method to add it to the TableDefs collection of a Database.

To refer to a CdbTableDef object in a collection by its ordinal number or by its Name property setting, use either of the following syntax forms:

TableDefs[0]

TableDefs["name"]

CdbTableDef Constructor Syntax

Use any one of the following three constructors. The qualifier 'CONSTRUCTOR' in the syntax models is provided to help readability. It has no syntactic value.

CONSTRUCTORCdbTableDef(VOID);

This constructor creates an instance of the class. There are no parameters.

CONSTRUCTORCdbTableDef(const CdbTableDef &);

Type Description
const CdbTableDef & Reference to an object.

This constructor creates a copy of the object referenced in the parameter.

CONSTRUCTORCdbTableDef(DAOTableDef *ptd,

BOOL bAddRef = FALSE);

Type Argument Description
DAOTableDef * ptd A DAO Automation interface pointer corresponding to this DAO class.
BOOL bAddRef

=FALSE

Optional. A Boolean. If TRUE, the DAO Automation interface AddRef function is called.

DAO functionality is presented through pointers to DAO Automation interfaces. This constructor makes a DAO interface available in the form of a DAO class object that provides additional functionality.

This constructor is not required for typical use. It is provided to enable you to easily create a DAO class object if you have access to the corresponding DAO interface.

When the destructor for the DAO object is invoked, the underlying Automation interface's Release member is called. If Release decrements the interface's reference count to zero, the pointer to the Automation interface can be deleted. If you don't want this to happen (for example, because you want to discard the DAO object, but continue using the Automation interface), specify TRUE for the second parameter. The underlying Automation interface's AddRef member is called, which counterbalances the eventual call to Release.