Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have developed a database application in visual studio 2010 using c#. All is running well but when I install it in any other user pc or move the application to other folder in my pc the application shows error. It cannt locate the database directory.How can i enable my application to check the database directory automatically? and change the connection string accordingly to run the app properly?
pls help...
Posted

1 solution

Options:
1. Use configuration(or App Settings)
2. Access data from a Shared folder.
3. Always keep data in a relative location to the main exe.
Eg: Let Your application path is D:\MyAppFolder\myapp.exe
Let your data path is D:\MyAppFolder\MyData\SomedatabaseFile.ext
So your DB can be accessed as :
C#
string DBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MyData\\Somedb.mdb");
 
Share this answer
 
v2
Comments
faisal_ruet 18-Sep-12 3:17am    
Thank You.
Perfect Solution.
I have checked that.
Kuthuparakkal 18-Sep-12 3:20am    
you're most welcome!
faisal_ruet 18-Sep-12 3:34am    
Can you give me a solution ...How can I develop android in Visual Studio using c# ?
Kuthuparakkal 18-Sep-12 3:37am    
go with Mono:
http://xamarin.com/monoforandroid

You may also look at:
http://stackoverflow.com/questions/1371939/how-can-i-use-ms-visual-studio-for-android-development

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