OPEN DATABASE Command

Example   See Also

Opens a database.

Syntax

OPEN DATABASE [FileName | ?]
  [EXCLUSIVE | SHARED]
  [NOUPDATE]
  [VALIDATE]

Arguments

FileName

Specifies the name of the database to open. If you don't specify an extension for the file name, Visual FoxPro automatically assigns a .dbc extension. If you omit FileName, the Open dialog box is displayed. You can specify a path name as part of the database name.

Note   Visual FoxPro will not recognize a path name properly if a disk or directory name contains an exclamation point (!).

?

Displays the Open dialog box from which you can choose an existing database or enter the name of a new form to create.

EXCLUSIVE

Opens the database in exclusive mode. If you open the database exclusively, other users cannot access it and will receive an error if they try to gain access. If you do not include EXCLUSIVE or SHARED, the current SET EXCLUSIVE setting determines how the database is opened.

SHARED

Opens the database in shared mode. If you open the database for shared use, other users have access to it. If you do not include EXCLUSIVE or SHARED, the current SET EXCLUSIVE setting determines how the database is opened.

NOUPDATE

Specifies that no changes can be made to the database. In other words, the database is read-only. If you omit NOUPDATE, the database is opened with read/write access.

Tables contained in the database are not affected by NOUPDATE. To prevent changes to a table in the database, include NOUPDATE in USE when you open the table.

VALIDATE

Specifies that Visual FoxPro ensures that references in the database are valid. Visual FoxPro checks to see that tables and indexes referenced in the database are available on disk. Visual FoxPro also checks to see that referenced fields and index tags exist in the tables and indexes.

Remarks

While the database is open, all tables contained in it are available. However, the tables are not implicitly opened. You must open them with USE.

When USE executes, Visual FoxPro looks for the table within the current database. If the table isn't found, Visual FoxPro then looks for a table outside the database. This means that if a table in a database has the same name as a table outside the database, the table in the database is found first.

You cannot open a database that has been opened exclusively by another user.