I have a VB.NET app that connects to a SQL Server.
We recently added database mirroring in case of a server failure.
Well of course, our SQL Server failed but the VB.NET app is not failing over.
I found that in our code, a failover partner wasn't specified in the connection string so I updated the connection string as follows:
sConnectionString = "Data Source=PROD-SQL;Failover Partner=FAILOVER-SQL;Initial Catalog=DB;User ID=****;Password=******;"
The SqlClient.SqlConnection
object accepts this connection string but when I call its .Open()
command it fails with the following error:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
Why is this? Our intranet apps failed over just fine (Classic ASP using DSN-less connections).
Does the application have to make at least one successful initial connection to the primary server before it can failover successfully?
Thanks!
Run this on your principal db
The value returned in mirroring_partner_instance is the server name that will be used by your connection for failover, not FAILOVER-SQL. FAILOVER-SQL will be used when it first tries to get a connection but cannot contact PROD-SQL. If PROD-SQL is available the failover partner will be set in cache from the sql server value mirroring_partner_instance.
See here for more info: http://blogs.msdn.com/b/spike/archive/2010/12/15/running-a-database-mirror-setup-with-the-sqlbrowser-service-off-may-produce-unexpected-results.aspx