locked
Connectionstring: retrieve data source from public function RRS feed

  • Question

  • All I have a Visual Studio 2010 application which uses an MS-Access database in background.

    In app.config there is now something like

    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="Plant.My.MySettings.dashboardConnectionString1"
                connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&quot;C:\Plant\dashboard.accdb&quot;"
                providerName="System.Data.OleDb" />
        </connectionStrings>


    The application is now going to be used on a second computer, but it should use exact same database. That's why I need to move the file to a server. Furthermore, I want to be sure the application keeps working in case e.g. the server gets replaced or the file moves to another location for some reason. I already use a setting.ini file and have a public function ReadIniFile(strType) which reads out this INI-file and returns the value of the given parameter.  I extended the INI-file with an entry "DATABASELOCATION:\\serverx\folder\database.accdb".

    I now need to modify app.config in such way the function is used to retrieve the location, but this fails:

    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="Plant.My.MySettings.dashboardConnectionString1"
                connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&quot;" & ReadIniFile("DATABASELOCATION:")&quot;"
                providerName="System.Data.OleDb" />
        </connectionStrings>



    • Edited by ino_mart Tuesday, April 19, 2016 7:23 AM
    Tuesday, April 19, 2016 7:21 AM

Answers

  • Hi ino_mart,

    Could you please tell us what project type are your create?

    This forum is discuss Visual Studio LightSwitch application development problems.

    According to a feedback in Visual Studio User Voice, the LightSwitch seems not support MS Access database. So please tell us your project type which can let us find out a appropriate forum to get a better help for your problem.

    https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/2138587-connecting-to-ms-access-mdb-as-an-external-data-so

    If misunderstanding, please feel free to let me know.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.


    • Edited by Weiwei CaiModerator Monday, April 25, 2016 6:38 AM
    • Proposed as answer by Angie Xu Thursday, April 28, 2016 6:15 AM
    • Marked as answer by Angie Xu Thursday, April 28, 2016 6:15 AM
    Monday, April 25, 2016 6:37 AM
    Moderator