0

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.

2 Answers 2

2

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.

1
  • :D I definitely give it a try!
    – Deltax76
    Jan 27, 2010 at 17:10
0

Solution that works for me:

Data Source=[MSSQLPrincipalServerIP,MSSQLPORT];Failover Partner [MSSQLMirrorServerIP,MSSQLPORT];Initial Catalog=DatabaseName;Persist Security Info=True;User Id=userName; Password=userPassword.; Connection Timeout=15;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .