Click here to Skip to main content
15,355,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am develope a project on Windows application and using access to set connection string dynamically so that when user install software on his machine it will run?

NABIN SEN 28-Nov-12 7:33am
how to set access database path not a sql server
For this, you may copy the access database file inside the user's AppData folder place at following path
//SystemDrive/Users/UserProfile/AppData or you may say C:/Users/ali/AppData/Roaming

to access this folder in C# write following


Place your access file here on either setup installation or at your application first time load. (depends on your logic or preference) and get connection from that path.
First to add Application configuration file into your solution & add the following in between <configuration> tag

    <add key="Your connection name" value="Your connection string"/>

For Access connection string follow the below link.[^]

using System.Configuration;
namespace in to your solution.
getting connection string from App.config
string connection_string=ConfigurationSettings.AppSettings["your connection name"]

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