Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write to program to connect to a database mirroring, and now I'm confused with the connection string. My database mirroring was installed on three SQL Server instances on three virtual PCs. I want my program to run on one of them and connect to the database. The database will be switched roles (principal becomes mirror, and vice-versa).

I know 2 connection strings, but I really doubt that there are some better solutions. Some solution to configure the database, so I don't have to switch the connection strings. In other words, the connection to database mirroring is transparent to the client. Clients don't know about the database mirroring, they just want to know the connection string. How can I do that?

Thank you very much to your help.

share|improve this question
up vote 2 down vote accepted

You must add the FailoverPartner to the connection string. And, as usual, there is an example on

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

Whenever you find yourself asking something about a connection string, just use the dedicated class SqlConnectionStringBuilder.

share|improve this answer
:D I definitely give it a try! – Vimvq1987 Jan 27 '10 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.