In order to change configuration settings within an application without restarting and to harness the power of a more intricate ability to manage user permissions, it is ideal to store connection strings and other data in an external file. Below I demonstrate how to make the web.config file call to an external file for a connection string. This can also be done for connection strings stored as keys in the appSettings tag.
<configuration> <appSettings/> <connectionStrings configSource=”conns.config”></connectionStrings> <system.web> </system.web> </configuration>
The conns.config file will then only contain a single section element and nothing else. Yes it is that simple.
<connectionStrings> <add name=”myConnectionString” connectionString=”Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:My Database Foldermydatabase.mdb; Jet OLEDB:Database Password=mypassword” providerName=”SQLOLEDB”/> </connectionStrings>


Sun, Aug 17, 2008
ASP.NET, Code