Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AppSettings file="user.config" for connectionstring in .NET2.0

19 views
Skip to first unread message

mortb

unread,
Apr 19, 2006, 2:51:48 AM4/19/06
to
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?


Mary Chipman [MSFT]

unread,
Apr 22, 2006, 7:39:12 PM4/22/06
to
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" <mo...@nospam.nospam>
wrote:

0 new messages