OPEN DATABASE Command
Opens a database.
Specifies the name of the database to open. If you do not 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.
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.
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.
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.
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.
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.
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 is not 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 is open exclusively by another user.
If you open a database twice in succession without closing the database, the database retains the same settings specified with the first DATABASE OPEN command. To change the settings, you need to close the database and then issue the DATABASE OPEN command with new settings. For example, if you open a database and specify EXCLUSIVE, the ISEXCLUSIVE function returns True (.T). If you run the DATABASE OPEN command using the same database and specify SHARED the ISEXCLUSIVE function still returns True (.T.). To open the database as shared, you need to close the database and then issue the DATABASE OPEN command using the SHARED keyword.
In the following example, OPEN DATABASE is used to open the testdata database. DISPLAY DATABASE is used to display information about the tables in the database.
CLOSE DATABASES SET PATH TO (HOME(2) + 'Data\') && Sets path to database OPEN DATABASE testdata && Open testdata database DISPLAY DATABASE && Displays table information