Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i installed setup the given connection string found ms access database is connected from my project folder,but i want database is connected to my installation folder where setup is installed .....

Your suggestion and help is highly apreaciated
thanks in advance

What I have tried:

private OleDbConnection con = new OleDbConnection();
string path = Environment.CurrentDirectory;

public void connection()
{
string pathfinal = path + "\\ECOFRESH.mdb;";
con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + pathfinal + ";Mode=ReadWrite;Jet OLEDB:Database Password=abc");
}
Posted
Updated 12-Mar-18 19:56pm
Comments
Richard Deeming 13-Mar-18 10:55am    
Access requires that the user running your application has permission to write to the folder where the database file is stored.

If you're installing into the "Program Files" directory, normal users won't have that permission.

1 solution

copy database in folder where exe is present and use fallowing code to set database path
in web config
<add name="constr"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CsvPhotoRename.accdb"
providerName="System.Data.OleDb" />

code behind

OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
 
Share this answer
 
Comments
satpal rawat 14-Mar-18 7:54am    
Thanks,But getting a error
Not a valid password
how to set in app.config file
dkamble 10358990 18-Mar-18 1:11am    
add Password=MyDbPassword; in connection string

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