Unanswered: How to get CDatabase to reconnect after SQL Server restart
I have an old application to maintain that uses CDatabase to connect to SQL Server. If SQL Server is stopped and restarted, such as in a cluster failover (i.e. move group), then the CDatabase connection needs to reconnect. It seems that it's not capable of doing this on it's own so I need to check the state some how. Various methods, such as IsOpen, seem to be useless as far as determining if I have a "good" connection.
That's pretty much what I was thinking too. I was hoping to not have to go over the wire just to verify the link. In OLEDB/ADO I've been able to use DBPROPVAL_CS_COMMUNICATIONFAILURE pretty reliably and was hoping someone might come back with something similar. Even a straight ODBC call passing the member connection handle.
Unfortunately the app isn't written in such a way that it's easy to trap and close up the connection and on a failure. CRecordsets are created on the stack all over the place with no encapsulation of the functionality. Some don't even have try...catch and just let the CATCH ALL handle it. Over the years people have kept adding functionality and used the same bad practices.