Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I developped a dll in C# and using database in ms-access, its working in my pc when i placed dll file and database in bin folder of application because below connection string i tried pick path of bin folder.

If i placed dll file and databace at other location then it gives error like
Could not find file 'c:\abc.mdb'.
.

So need a connection string which find the current location of dll and database at any place.
Thanks in advance.

What I have tried:

string appPath = Application.StartupPath;

con = new OleDbConnection(@"Provider=MICROSOFT.ACE.OLEDB.12.0;Data Source=" + appPath + "\\abc.mdb;Jet OLEDB:Database Password=mbd");
Posted
Updated 26-Mar-19 1:24am
Comments
F-ES Sitecore 26-Mar-19 7:16am    
Put the "appPath" in your config file so you can specify where to find the database.

1 solution

It's a bad idea to store data in the executable folder - in release versions that is under "program files" and access is restricted to prevent virus activity.
One way to do it is to store it in a "known location" which can move but still work: Where should I store my data?[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900