Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# database
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 9-Sep-12 20:50pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 :
string DBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MyData\\Somedb.mdb");
faisal_ruet at 18-Sep-12 3:17am
Thank You.
Perfect Solution.
I have checked that.
Kuthuparakkal at 18-Sep-12 3:20am
you're most welcome!
faisal_ruet at 18-Sep-12 3:34am
Can you give me a solution ...How can I develop android in Visual Studio using c# ?
Kuthuparakkal at 18-Sep-12 3:37am
go with Mono:
You may also look at:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100