Partager via


How to: Open Databases

To add, access, and edit items in a database, open the database. When you open a database, Visual FoxPro sets it as the current database and adds the database name to the database list on the Visual FoxPro standard toolbar. By default, items that you create or add to the database are associated with the current database, and commands or functions that manipulate open databases operate on the current database. You can also set another open database as the current database. For more information, see How to: Set the Current Database.

Note

Opening a new database does not close any currently open databases. However, the most recently opened database becomes the current database.

You can have multiple open databases at the same time. For example, you might open and use multiple databases when you run multiple applications with each using a different database. You might also want to open multiple databases to use information, such as custom controls, in a database that is separate from your application's database.

Note

Visual FoxPro might open one or more databases automatically when you execute a query or a form that requires opening databases. To make sure you are working with the correct database, set the current database explicitly before using any commands that operate on the current database. For more information, see How to: Set the Current Database.

Opening the database in the Database Designer makes it possible for you to view the database schema, a visual representation of the database, and work with the tables associated with it, the relationships between those tables, and other items in the database. To view the structure of the database (.dbc) file itself, see How to: View Database Structure.

To open a database in the Database Designer

  1. On the File menu, click Open.

  2. In the Open dialog box, browse for and select the database (.dbc) file you want to open.

  3. Click OK.

    The database you selected opens in the Database Designer, which displays any items it contains and any relationships between them.

For more information, see Database Designer (Visual FoxPro).

To open a database in a project

  1. Open the project in the Project Manager.

  2. In the Project Manager, expand the Data node, then the Databases node.

  3. Click the name of the database you want to open.

  4. Perform one of the following:

    • To open the database without opening the Database Designer, click Open or expand the node for the database.

    -OR-

    • To open the database in the Database Designer, click Modify.

      The database you selected opens in the Database Designer, which displays any items it contains and any relationships between them.

For more information, see Project Manager Window.

To open a database programmatically

  • Perform one of the following:

    • To open the database without opening the Database Designer, use the OPEN DATABASE command.

      -OR-

    • To open the database in the Database Designer, use the MODIFY DATABASE command.

For more information, see OPEN DATABASE Command and MODIFY DATABASE Command.

See Also

Other Resources

Working with Items in Databases

Creating Databases

Managing Databases

Developing Databases