次の方法で共有


OPEN DATABASE Command

Opens a database.

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

Parameters

  • 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.

Example

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

See Also

ADD TABLE | CLOSE DATABASES | CREATE DATABASE | DBUSED( ) | DISPLAY DATABASE | FREE TABLE | LIST DATABASE | REMOVE TABLE