views:

1919

answers:

3

Hi, I have a windows application connecting to Database to read some data. Since the database is setup for resilience, my application needs to connect to one of the two databases. Can someone specify the what the syntax would be to specify the failover partner in a connection string using sql server authentication.

Any help is greatly appreciated.

+2  A: 

Check connectionstrings.com:

Database mirroring
If you connect with ADO.NET or the SQL Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial
Catalog=myDataBase;Integrated Security=True;

There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

Joel Coehoorn
Hi Joel, Thanks for your resposne, will this work even if I don't have mirroring setup?
Vineet
+1  A: 

If you supply the name of a failover partner server in the connection string, the client will transparently attempt a connection with the failover partner if the principal database is unavailable when the client application first connects.

";Failover Partner=PartnerServerName"

If you omit the name of the failover partner server and the principal database is unavailable when the client application first connects then a SqlException is raised.

Source

Adam Hughes
Thanks Adam. This should work for me.
Vineet
A: 

I am having a similar issue but I am using Oracle. Is there any way to add "Failover Parter" into the connection string for Oracle? Thanks.

dave