2011-09-23 62 views
0

我的一些網站都報道了以下錯誤:來自SqlException的連接字符串「網絡相關或實例特定的錯誤?」

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

該網站動態切換連接字符串和我懷疑的問題是,它是不正確的事情了。如果我可以提取它未能連接的服務器名稱,我可以進一步調查。

有沒有什麼辦法可以做到這一點,比如說,Application.Error在global.asax中?

+0

您必須將日誌記錄添加到啓動連接的代碼塊,錯誤時的全局asax只會記錄上面顯示的SqlException,可能有必要檢查InnerException但它可能有它 – kd7

回答

-1

這可能是由於SQL Server服務停止運行引起的。打開SQL Server Configuration Manager並重新啓動SQL Server服務。

相關問題