Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 down vote accepted

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

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
add comment

Your Answer

 
discard

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.