Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My application is LAN based.I want to provide the path of access database relative where every machine can access that database which is on server machine.
AND also when i am moving application on another machine then i have to change my source path manually every time then what is solution..
I try following and previous code is.please help me.Thanks
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\vishal_WPF_Final\MTDLL_TEACHER\MTDLL_TEACHER\student.mdb";

and i try like this too:
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
Posted
Updated 17-May-11 20:18pm
v3

I dont think you need to worry about the relative path. First, make sure that your access database is placed in a central location accessible to all machines (i.e. Windows allows you to access this file).

Once that is done, you can look at defining the relative path or set up a connection string.
 
Share this answer
 
Comments
vishal_h 18-May-11 2:16am    
sir thanks but when i am moving my application to another machine then i want to change the path every time..so what is solution
Abhinav S 18-May-11 2:24am    
The best you can do is set the path in a configuration file or settings file - if you are going to move the database very often. Read the settings file and then open the connection.
vishal_h 18-May-11 3:04am    
but sir its not working my application is in WPF ..can you tel me please what i have to write in data source=...
vishal_h 18-May-11 3:28am    
Sir i have done by copy that database file in debug folder and given the path in
string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase ;
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path +@"\student.mdb";
Wonde Tadesse 9-Nov-11 12:05pm    
My 5+
In addition to Abhinav S solution, make sure the folder that contains the database is shared and has read/write access permission. So user will able to access it without difficulty.
 
Share this answer
 
me too having same problem about relative path in WPF...
anybody..
please help
 
Share this answer
 
Comments
Marc A. Brown 9-Nov-11 12:08pm    
You need to post your problem, with specifics, as a separate question.

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