A portal application

zhshqzyc used Ask the Experts™
Hi I have two sql server instances, one is normal and the other is backup mode that is the replication of the normal.

I have a portal in the web site. For a specific group in database and users in AD can login in backup mode. For others, they can login normal one.
Now I am using configuration file to swith the connection strings manully.

How to do it automatelly with code?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I would assume you have some way to detect which user they are. If that is the case:

<add name="LiveDBConnection" connectionString="MyLiveConnection"/>
<add name="BackupDBConnection" connectionString="MyBackupConnection"/>

    connection.ConnectionString = ConfigurationManager.ConnectionStrings["BackupDBConnection"].ConnectionString
    connection.ConnectionString = ConfigurationManager.ConnectionStrings["MyLiveConnection"].ConnectionString

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial