Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to mirrored SQL Server after failover?

I set up a database mirroring and then used this connectionstring to connect to it:

    Data Source={0};Failover Partner={1};Initial Catalog=AdventureWorks;
    Integrated Security=True;

After adding some data into database, I shutdown the principal server, so the mirror server becomes the principal server. I open the connection again, an get this error:

    System.Data.SqlClient.SqlException: A transport-level error has 
occurred when sending the request to the server. (provider: Shared Memory 
Provider, error: 0 - No process is on the other end of the pipe.)

I thought that with Failover Partner specified in the connection string, ADO.NET would do the work for me. So what should I do now?

like image 417
Quan Mai Avatar asked Feb 04 '10 15:02

Quan Mai


People also ask

How do I resume a suspended mirroring in SQL Server?

To pause or resume database mirroring During a database mirroring session, connect to the principal server instance, in Object Explorer, click the server name to expand the server tree. Expand Databases, and select the database. Right-click the database, select Tasks, and then click Mirror.

Does mirroring support automatic failover?

The mirror server initiates automatic failover only if the mirror and the witness remain connected to each other after both have been disconnected from the principal server.

Can you read from a mirrored database?

Means if we change a page on the mirrored database, we will copy its origin state over to the snapshot. Means instead reading it from the origin database, the snapshot now will read it out of its own file.

What are the options that can be used to automatic failover in mirroring?

Automatic failover is supported only in database mirroring sessions running with a witness in high-safety mode (high-safety mode with automatic failover). In high-safety mode with automatic failover, once the database is synchronized, if the principal database becomes unavailable, an automatic failover occurs.


1 Answers

Fortunately, I fixed this problem. All I need to do is calling ClearPool method:

SqlConnection.ClearPool(conn);

This method will clear the connection pool. Then, the problem's gone. I'm so happy with it.

Thank you, all of you, for your support. :D

like image 86
Quan Mai Avatar answered Oct 15 '22 08:10

Quan Mai