DAO External: Creating an External Table

HomeOverviewHow Do IFAQSampleTutorialODBC Driver List

This article explains how to create a new table, with the correct format, in an external data source. For general information about external data sources, see the article DAO External: Working with External Data Sources.

To create an external table

  1. Open the external database directly.

    Construct a CDaoDatabase object and call its Open member function. Pass the appropriate connection information.

    You can’t manipulate the schema of an attached table, so you must open directly.

  2. Create a tabledef for the new table.

    Construct a CDaoTableDef object based on the CDaoDatabase object. Call the tabledef object’s Create member function, specifying connection information and the name of the source table on which the tabledef is based.

    As an alternative, you could accept the default parameter values in Create, then call SetConnect and SetSourceTableName.

  3. Add fields to the new table.

    Call the tabledef object's CreateField member function. The new field is automatically appended to the underlying DAO tabledef object's Fields collection.

  4. Create the external data file by appending the tabledef object to the CDaoDatabase object's TableDefs collection.

See Also   DAO: Where Is..., DAO External: Working with External Data Sources, DAO External: Attaching External Tables, DAO External: Refreshing and Removing Links