Hi! To ensure that my development connectionstring wasn't the one used for our live website I have used a development configuration file that overrides the appsettings section. Syntax as follows: <appSettings file="..\user.config"> <add key="ConnStr" value=" .. "/> </appsettings> I thought this worked really good allowing me to keep my development connection string from beeing checked into sourcesafe. However, in .Net 2.0 there is a new section <connectionStrings /> . Is it possible to override this section as well or does someone have an equal, or even better, solution?
Yes, check out external configuration files. You can store a configuration file fragment consisting of a single section in a separate file and reference it from your web.config file. Your web.config configuration section would look like this: <?xml version='1.0' encoding='utf-8'?> <configuration> <connectionStrings configSource="connections.config"/> </configuration> And your external connections.config file would look like this (do not type in any other tags or directives): <connectionStrings> <add name="Name" providerName="System.Data.ProviderName" connectionString="Valid Connection String;" /> </connectionStrings> You then use the ConfigurationManager or WebConfigurationManager to retrieve it by name or provider name. --Mary On Wed, 19 Apr 2006 08:51:48 +0200, "mortb" <mortb@nospam.nospam> wrote: >Hi! > >To ensure that my development connectionstring wasn't the one used for our >live website I have used a development configuration file that overrides the >appsettings section. Syntax as follows: > ><appSettings file="..\user.config"> > <add key="ConnStr" value=" .. "/> ></appsettings> > >I thought this worked really good allowing me to keep my development >connection string from beeing checked into sourcesafe. >However, in .Net 2.0 there is a new section <connectionStrings /> . Is it >possible to override this section as well or does someone have an equal, or >even better, solution? >