Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single Connection string control multiple database connection on case condtion

Status
Not open for further replies.

Farrukh hameed

Programmer
Apr 13, 2018
3
IQ
HI Experts !
I am not sure right area to put my question sorry !

I have multiple databases on different servers , the issue I am facing a downtime if principal server goes down the application cannot able to connect to mirror server ( when failover happens auto & mirror server comes to principal, synchronized ). Is there is a way the below two connection works on condition. suppose if the Main principal server database online then connect to that database else look for other connection string to connect other database(DB2).

<application id="Virtual_Machine">
<description>Virtual_Machine</description>
<database>
<driver>SQLSERVER</driver>
<sqlsyntax>SQLSERVER</sqlsyntax>
<connectString>Data Source=Computername1;Initial Catalog=DB1;User ID=sa;Password=*****;Application Name=testapp</connectString>
</database>
</application>

<application id="Virtual_Machine1">
<description>Virtual_Machine1</description>
<database>
<driver>SQLSERVER</driver>
<sqlsyntax>SQLSERVER</sqlsyntax>
<connectString>Data Source=Computername2;Initial Catalog=DB2;User ID=sa;Password=*****;Application Name=testapp</connectString>
</database>
</application>
 
if it is a failover cluster then you should be connecting to the cluster SQL name, not the individual nodes
if it is a AG setup then you should be connecting to the AG listener, not the individual nodes.

And in both cases the DB name would be the same, not db1 and db2 as you mention above - or is it that you have replication active to a different db name? that is not ideal and for those you do indeed need to change connection strings.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top