
Signature
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
> I have done exactly as you stated in ASP.NET 1.1 by preferencing my
> connection string names with the machine name. Then in the
[quoted text clipped - 4 lines]
> This works great for a connection string that I am going to be using for
> data access within my code.
OK.
> But what about for the membership/role providers where the
> connectionStringName is specified in the web.config file. Can I
> dynamically
> change the provider's connectionStringName in the Application_Start
> method?
> If so how do I do that? (tried but couldn't figure it out).
Ah - I have to confess that I don't know for certain without some
experimenting of my own - I never use any of the Membership stuff...
However, Web Deployment Projects would *certainly* do this for you because
it allows different builds to replace various sections of the web.config
file...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Steven Cheng[MSFT] - 06 Jul 2007 04:08 GMT
Hi Pat,
Yes, for ASP.NET 2.0 web application, if you want to use different
connectionstrings for different scenario, all the available approaches are
as below:
** add multiple connectionstrings and load them dynamically in code depend
on which one to use
** use Web Deployment project, thus, you can choose to set the certain c
onfiguration section(such as connectionstring) to a specifc value at
precompile/publish time. However, after that , the application still
statically load the fixed connectionstring from web.config file
http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx
** .NET 2.0 configuration file provide a "configSource" which can let you
define the content of a configuration section in a separate file. Thus, you
can define multiple separate files(contains connectionstrings for different
scenarios) and change your main web.config file to use the certain one
depend on which one will be used:
#SectionInformation.ConfigSource Property
http://msdn2.microsoft.com/en-us/library/system.configuration.sectioninforma
tion.configsource.aspx
#ASP Net - if statement in web.config file
http://www.velocityreviews.com/forums/t121932-if-statement-in-webconfig-file
html
Anyway, so far web.config file doesn't direcctly support dynamic (or
if...else... like) loading mechanism.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Mark Rae [MVP] - 06 Jul 2007 09:02 GMT
> Hi Pat,
Your newsreader continues to post your messages in the wrong place in the
thread...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
PatB - 06 Jul 2007 12:28 GMT
Mark,
What are you talking about? They seem to be in the right place to me.
I am using the Microsoft browser newsreader.

Signature
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
> > Hi Pat,
>
> Your newsreader continues to post your messages in the wrong place in the
> thread...
Mark Rae [MVP] - 06 Jul 2007 12:36 GMT
> What are you talking about? They seem to be in the right place to me.
Steven's reply to you appeared under my previous post i.e. as if he was
replying to me, not you...
> I am using the Microsoft browser newsreader.
I'm using Windows Mail

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Steven Cheng[MSFT] - 09 Jul 2007 04:28 GMT
Hi Mark,
Thanks for your reminder, actually I did know that I reply to your last
message, I did it just want to keep all the messages in a single path
rather than break the thread into multiple subtrees.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.