Click here to Skip to main content
15,868,141 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 database.how to set connection string dynamically so that when user install software on his machine it will run?
Posted

 
Share this answer
 
Comments
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
C#
//SystemDrive/Users/UserProfile/AppData or you may say C:/Users/ali/AppData/Roaming


to access this folder in C# write following

C#
Environment.SpecialFolder.ApplicationData


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.
 
Share this answer
 
First to add Application configuration file into your solution & add the following in between <configuration> tag

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

For Access connection string follow the below link.
http://www.connectionstrings.com/access[^]

Add
using System.Configuration;
namespace in to your solution.
getting connection string from App.config
string connection_string=ConfigurationSettings.AppSettings["your connection name"]
 
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