Click here to Skip to main content
12,954,199 members (50,193 online)
Rate this:
 
Please Sign up or sign in to 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 9-Sep-12 19:50pm

1 solution

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

Solution 1

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 :
string DBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MyData\\Somedb.mdb");
  Permalink  
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,464
CHill60 3,490
Maciej Los 3,123
ppolymorphe 2,020
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2017
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