如果数据库已关闭,我正在尝试使代码进入休眠状态。一切正常。我正在通过捕获异常来检查数据库是否可用,然后正在检查异常消息。是否有任何方法,例如异常类型,错误号.....
if (ex.Message == "The underlying provider failed on Open." || ex.Message == "A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)")
{
CheckConnection();
}