This is a migrated thread and some comments may be shown as answers.
Managing Open Access Configuration from the Web.config file
1 Answer 57 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
julien test
Top achievements
Rank 1
julien test asked on 09 Feb 2010, 03:33 PM
Hi,

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,

Julien.


1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 10 Feb 2010, 08:05 AM
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:
<connectionStrings>
   <add name="DatabaseConnection1" connectionString="data source=(local)\SQLEXPRESS;initial catalog=Northwind;integrated security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

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,
Alexander
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.
Tags
Development (API, general questions)
Asked by
julien test
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or