none
DataDirectory RRS feed

  • Question

  • All,

    Using: VB-2012 / SQL Compact 4.1

    Currently my VB10 application loads looking in My.Settings for the backend .sdf database file path. Once set, each application launch is successful. If it is a new install the end-user simply navigates to the database file and its location is saved to My.Settings for its future path. No problems.

    The problem is that if the system Admin changes the database file location all my installs launch looking for the new database path as expected.

    Now, what's this DataDirectory thing all about? Can I use this to help me/system Admin with the backend database issue?

    I created an option for the Admin that they can save the database path in an xml file and they simply edit that file if they move the backend database file to a new location. All my installs are looking at that location within my.Settings and once the Admin copies/moves the database file to the new location and then edits the xml file, all is good.

    I need some ideas. Is what I'm doing okay or is there a better way to do this?

    ADawn



    ADawn


    Monday, March 4, 2013 4:41 PM

Answers

  • I don't think the DataDirectory macro will help in this instance. The value it returns is the path set by:

    AppDomain.CurrentDomain.SetData("DataDirectory", newpath)

    In any event you would need to provide the new path to the app so it can change it. You could also use an application setting in the App.config file for the connection, but that would need to be changed as well when the Admin moves the database file.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, March 5, 2013 1:49 PM