|
<< Click to Display Table of Contents >> Step 3: Set the database object to point to the directory containing the table |
![]() ![]()
|
Once the database is open, use the DbiSetDirectory function to point the database to the directory containing the table: the "working directory". The working directory is the directory where the BDE expects to find tables when a path is not specified in the table reference. The working directory for a BDE database defaults to the directory containing the application’s executable file. Even if the data tables are in this directory, it is a good practice to explicitly set this directory. It becomes necessary when the data files are stored in a different directory or on a database server.
While it is possible to open a table in other directories by specifying the absolute path, it is preferable to open tables in the working directory, because a number of operations, such as getting a list of available tables, use the current directory.
The following example shows how to use the DbiSetDirectory function to set the working directory to that containing the target table for this demonstration. The call to DbiSetDirectory uses the database handle derived in the preceding step to associate the directory with that database.
Check(DbiSetDirectory(hDb,
"c:\\Program Files\\Borland\\Borland Shared\\Data"));
| Note: | You must use the full, absolute path. Relative paths are not supported. |