asp.netvisual-studio-2010web-configweb-config-transform

How can i use 2 connection string using OR condition Web.config in asp.net


How can i use 2 connection strings with same connection string name

but differ in IP using OR condition Web.config in asp.net

when any one fails other should respond.

First Connection string:

add name="ConnectionString" connectionString="Data Source = 10.10.1.1\SQLEXPRESS ; Database = stores; User ID = sa; pwd = ********" providerName="System.Data.SqlClient"

Second Connection string:

add name="ConnectionString" connectionString="Data Source = 10.10.1.2\SQLEXPRESS ; Database = stores; User ID = sa; pwd = ********" providerName="System.Data.SqlClient"


Solution

  • You dont need to add two connection strings, just add a fail over partner in connection string

    add name="ConnectionString" connectionString="Data Source = 10.10.1.1\SQLEXPRESS ; Failover Partner= 10.10.1.2\SQLEXPRESS ; Database = stores; User ID = sa; pwd = ********" providerName="System.Data.SqlClient"