HighTechTalks DotNet Forums  

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

Dotnet Data Tools microsoft.public.dotnet.datatools


Discuss AppSettings file="user.config" for connectionstring in .NET2.0 in the Dotnet Data Tools forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mortb
 
Posts: n/a

Default AppSettings file="user.config" for connectionstring in .NET2.0 - 04-19-2006 , 01:51 AM






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?



Reply With Quote
  #2  
Old   
Mary Chipman [MSFT]
 
Posts: n/a

Default Re: AppSettings file="user.config" for connectionstring in .NET2.0 - 04-22-2006 , 06:39 PM






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 (AT) nospam (DOT) nospam>
wrote:

Quote:
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?


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.