none
Relative path to Access database RRS feed

  • Question

  • How can I specify a relative path to the Access database?

     

    Something like:

    Data Source=|DataDirectory|\..\..\..\ABSData.mdb

     

    It is a rather huge database updated regularily to copy it every time I try to compile the project. Relative path would allow me to exclude it from the project files (especially, that I have two projects on the same database)

     

    Monday, March 3, 2008 3:29 PM

All replies

  • Does the DataDirectory macro not work for you? Where is the database going to be relative to the applications?

    Monday, March 3, 2008 4:55 PM
  • depends (since it is shared by two projects). but during the development process it is three folders above the execution folder

     

    ps. and it is not a web project

    Monday, March 3, 2008 5:21 PM
  • If it is database that shared among multiple projects then I would suggest creating separate folder on a hraddrive and point to the folder using full path. This folder should NOT be subfolder of any project and it will allow you to keep this path consistent, and you do not need to change it unless you decided to move database into completely different location. I believe it is better approach rather than analyzing what would be correct relative path for each application. In addition, if you move your connection string into configuration file of application, you do not need to recompile your code to make a change to the path of the database.

     

    Tuesday, March 4, 2008 10:56 AM
    Moderator