Click here to Skip to main content
Sign Up to vote bad
good
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 - 19:50


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 :
string DBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MyData\\Somedb.mdb");
  Permalink  
Comments
faisal_ruet - 18 Sep '12 - 3:17
Thank You. Perfect Solution. I have checked that.
Kuthuparakkal - 18 Sep '12 - 3:20
you're most welcome!
faisal_ruet - 18 Sep '12 - 3:34
Can you give me a solution ...How can I develop android in Visual Studio using c# ?
Kuthuparakkal - 18 Sep '12 - 3:37
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 211
1 Richard MacCutchan 145
2 Sergey Alexandrovich Kryukov 134
3 Tadit Dash 124
4 Santhosh G_ 120
0 Sergey Alexandrovich Kryukov 10,338
1 OriginalGriff 7,965
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid