0
Reply

Windows Service login error after database failover

Richard van Schie

Richard van Schie

13 years ago
8.3k

I've created a windows service that connects to a database. My connection string supports the Failover Partner.
SqlConnection
conn = new SqlConnection("Persist Security Info=False;User ID=user;Password=xxx;Data Source=Server_A;Initial Catalog=DatabaseName;Failover Partner=Server_B");
When the database is running on the main-server, all is working well. When I do a failover, the service errors with: Cannot open database "DatabaseName" requested by the login. The login failed.
I know that both SIDS of the user are the same. When using a webapplication on the same database with the same user everything works fine. Using domain accounts results in the same error. When failing back to the main-server everything is working fine again.
Does anyone have any solution?