Could not find file

Problem

You get this error when running your application:

Unable to connect to database.  Could not find file ‘XXX’.

(I) ensure that MDAC 2.6 or higher is installed on your machine.

(II) Enable access to the temporary directory used by Microsoft Access:

A similar message indicates ‘Not a valid file name”.

These errors typically occur when an incorrect Microsoft Access database file name is listed in the Data Source entry in your application’s Web.config file.

Solution

If you are using Microsoft Access, then update the Data Source entry in your application’s Web.config file to use a correct path and file name.

<add key="DatabaseJobApplication.mdb1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=JobApplication.mdb;Jet OLEDB:Database Locking Mode=1;Mode=16" />

Use a relative path name when your Microsoft Access database file (MDB) is located within your application’s folder.  In general, it’s best to use relative path names when possible, so that your application and its database can be relocated by simply moving its folder.  Examples of relative paths are:

JobApplication.mdb

Databases\JobApplication.mdb

..\MyApp\JobApplication.mdb

Use an absolute path name when your Microsoft Access database (MDB) is located outside of your application’s folder.  Examples of absolute paths are:

C:\Applications\MyApp\JobApplication.mdb

See Also

Part IX:  Troubleshooting Applications

Application Will Not Run

Application Runs But No Data is Displayed

Application Error Messages