Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I work in windows form application works in c# visual studio 2015 connect to database
access 2007

my connection as bellow

C#
public static string fileName = @"\\192.168.1.30\data\accessqr.accdb";
 public string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0}", fileName);


it working without any problem

but if i need to move database access file accessqr.accdb in another network or

another place

may be no ip 192.168.1.30 available or no drive D: available so that

how to make connection dynamic to accept any network ?

so that i need my connection dynamic and is suitable to any place
what i do ?


What I have tried:

how to change the location of database file dynamically in another networkHow do I...
Posted
Updated 28-Mar-17 7:05am

1 solution

Store your connection string in the application's configuration file:
Connection Strings and Configuration Files[^]
How to: Read Connection Strings from the Web.config File[^]
How to get Connection String from App.Config in C#[^]

That way, you won't need to recompile if you move the database.
 
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