-1

Context:

Okay so I'm working on a project for my computer science coursework where I have to use two databases to pull information into a relatively simple form based management system. I'm using this connection string:

Problem:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ResourceData.accdb"

My database is in the debug folder as instructed by my teacher so that packaging up and handing the system to the client is easily done, but when I run the system, it keeps making copies of the database in the directory where my program is stored, outside of the debug folder, and then referencing that copy when it comes to updating the database.

Aluan Haddad
  • 29,886
  • 8
  • 72
  • 84
tevr0c
  • 1

1 Answers1

0

If you are going to have the database always in the same folder as the compiled EXE file, you can use connection string without the |DataDirectory| tag:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ResourceData.accdb"

Jan Šotola
  • 842
  • 8
  • 25
  • Will this work even through the development phase or is this just when it's in exe form – tevr0c Mar 29 '18 at 13:45
  • In the development phase, the DB file is expected to be in the `debug/bin` folder (where the EXE resides as well). In the production phase, the DB file is expected be in that folder, where you copy the EXE file. However, the same behavior should be obtained using the original connection string. For further description of the |DataDirectory| tag see [here](https://stackoverflow.com/a/12276625/373126) – Jan Šotola Mar 29 '18 at 14:27