0

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

enter image description here

1
  • Please give more details. Commented Feb 15, 2013 at 7:20

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

thats strange.. can you please give some more details about your problem? and when you use the connectionString from my answer.. what is the error?
before i can create setup file for the application, i changed the connection string as string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/Database.accdb ;Persist Security Info=False;"; and then i created the set up file where i put my databse in this location. ProgramFiles/AmritCreation/MyAppName/..
Did you try to place your database and your application.exe in the same folder?
Both are inside the My Product Name Directory..Please check pic above
okay.. again try to place your database file and your running application.exe in the same directory.. I mean try move your database file in that folder Project Management. or in Bin folder in the project solution and use the connectionString above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.