Reputation: 1916
I am working on windows form which uses microsoft access database.
When the application will be installed, the database will be on this location C:\Program Files (x86)\Amrit\trial\Database.
How can i make this work so that this application will linked to the database when installed in my computer.
Can somebody give me easy solution.. Currently my connection string looks like this..
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Amrit\\Desktop\\Database.accdb ;Persist Security Info=False;";
when i create setup file for appplication, the database will be in ProgramFiles/AmritCreations/AppName/Database.accdb
Upvotes: 0
Views: 5507
Reputation: 7092
Just place your database and your application in the same directory and use this connectionString
string connString = "Provider=MICROSOFT.ACE.OLEDB.12.0; " +
"Data Source=|DataDirectory|/Database.accdb";
In times you're creating a Setup Project
, try to place the database file and [yourProjectName].exe in the same directory.
Upvotes: 1