Managing Open Access Configuration from the Web.config file

Thread is closed for posting
2 posts, 0 answers
  1. julien test
    julien test avatar
    15 posts
    Member since:
    Oct 2009

    Posted 09 Feb 2010 Link to this post


    I have a problem with configuration... I created a solution with 4 layers (DAL, BL, Common and UI, that are 4 different .NET projects)

    The UI layer is a web application configured by a web.config file. DAL, BL and Common are class library projects with an App.config file.

    The Common layer contains the persistents classes. Its App.config file contains a <connection> node (inside the <openaccess> node) with the database connection information. DAL and BL also have database connection information in their App.config.

    For the moment, Common, BL and DAL have each an App.config with a "Build Action" set to "Embedded Resource". Which means that if I need to change the database connection settings, I need to recompile the whole solution.

    Is there a way to setup the database connection information (connection string) only in the web.config file and make Open Access use this piece of information. Then I would be able to change the conntection settings on the fly without having to recompile my solution ?

    Thank you,


  2. Alexander
    Alexander avatar
    727 posts

    Posted 10 Feb 2010 Link to this post

    Hello julien,

    Yes, you can do this by specifying a connection string with the same name (as the one in the App.config of the Common project) in the global <connectionStrings> section of the Web.config file:
       <add name="DatabaseConnection1" connectionString="data source=(local)\SQLEXPRESS;initial catalog=Northwind;integrated security=True" providerName="System.Data.SqlClient" />

    You should already have this entry in the App.config, so just copy it from there and modify it if necessary. At runtime this connection string will override the one from the App.config. Hope that helps.

    Sincerely yours,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top