In my method, if I find that connection (System.Data.SqlClient.SqlConnection
) which I received has
State = Closed
State = Broken
which of the following approaches is correct?
Call Open()
to reconnect and continue with execution of subsequent statements. (Of course, I can also give the Open()
pre-configured number of retries.)
Throw such a connection away as unrecoverable and get brand new one.
(If these approaches are equal, I would prefer the first as easier to implement.)
(ConnectionState.Broken) The connection to the data source is broken. This can occur only after the connection has been opened. A connection in this state may be closed and then re-opened. (This value is reserved for future versions of the product.)
i.e. you can close and re-open the connection with Open(). If State is closed than you should throw an exception