0
在撰寫本文時使用Windows 10 Pro和VS2015 Pro進行所有更新。冉VS在安全模式和維修安裝Visual Studio沒有運氣。請注意,SSMS和其他應用程序可以隨時訪問數據庫。爲什麼重新啓動PC後重建會導致網絡錯誤?
該代碼可以簡化爲打開SQL數據庫連接;
Dim sqlCon As New SqlConnection("Server=server\instance;Database=database;User Id=…;Password=…")
sqlCon.Open()
'Works after reboot as many times as required but fails after build or rebuild!
Console.WriteLine(「Connection Opened」)
sqlCon.Close()
sqlCon.Dispose()
重建後的錯誤是;
Unhandled Exception: 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我想這是一個網絡相關的問題。 SQL Server服務設置爲「自動」啓動?也許它設置爲「延遲開始」? –