After you create a database, you can associate tables with a database by creating them in the database or adding existing ones. Tables can belong only to one database at a time; therefore you can associate any table that is not currently part of another database. If you want to associate a table that belongs to another database, you must remove that table before you can add it to a different database. You can also use data from another database table without removing it. For more information, see How to: Use Tables from Other Databases.
|To associate free tables with a database, you must explicitly add them. Modifying their structure does not associate free tables with a database, even if a database is open when you modify the structure.|
When you add a table to a database, Visual FoxPro modifies the header record in the table file to document the path and file name for the database that now contains the table. This path and file name information is called a back link because it links the table back to the owning database.
To create database tables, see How to: Create Database Tables.
To associate a table with a database
Open the database in the Database Designer.
The Database menu appears.
On the Database menu, click Add Table.
In the Open dialog box, browse for and select a table, and click OK.
The table you selected appears in the Database Designer.
To associate a table with a database in a project
Open the project in the Project Manager.
In the Project Manager, expand the Data node, and then the Databases node.
Click the Tables node, and then Add.
In the Select table name dialog box, browse for and select the table (.dbf) file you want to add, and click OK.
The table you selected appears in the Tables node of the Project Manager.
For more information, see Project Manager Window.
To associate a table with the current database programmatically
Open the database.
Use the ADD TABLE command.
For example, the following code opens a database named MyDatabase and adds a table called MyTable:
В Copy Code
OPEN DATABASE MyDatabase ADD TABLE MyTable
For more information, see ADD TABLE Command.