Click here to Skip to main content
15,888,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,
If we change our project's location (like we move it to another machine), each time we need to change path of the database for the connectivity , it is very tedious job to do so..

Most probably, I'm using MS Access Database, So can i have the proper solution so that i dont need to change the at every time?
Posted
Updated 7-Aug-12 21:54pm
v2

Usually you take such configuration out of your source code and put it into configuration files along side your application which you can change in deployment.
 
Share this answer
 
Option 1: Use a relative path. Something like '..\..\data\mydatabase.mdf'
Option 2: Use a database (SQL Server, for instance). Connect to it from all the relevant machines.

Hope this helps,

Pablo.
 
Share this answer
 
If the database travels with the application, then use localhost as the server name

If it's disconnected from the app, you can either use DNS CNAME[^] to alias it, or if you're feeling really confident, something like AD SCPs[^]

I am confused why a. you keep moving your app, and b. why that mandates a move of the DB?
 
Share this answer
 
hii ,
if you are using ms access then best option is to use odbc connection with DSN Connnection.
but if for are using ms access or any other databse use oledb with following way

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;

for further ref chk link

http://www.connectionstrings.com/access/[^]
 
Share this answer
 
used App-config file hardcoding connection string in project is bad coding you can used of App_config or web development web.config files.
always placed used of app-config or web.config file for connection
 
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