如何對連接到 SQL Server 的應用程式進行故障排除

如何對連接到 SQL Server 的應用程式進行故障排除

我正在嘗試讓 ASP.net StoreFront 連接到 Windows Server 2008 上的 SQL Server Express 2005。這篇 Microsoft 支援文章沒有成功。下面是錯誤。

[SqlException (0x80131904): 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)]
AspDotNetStorefront.Global.Application_BeginRequest(Object sender, EventArgs e) +286
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

在 Linux 系統上,如果我遇到此錯誤,我將使用 SQL 特定連線客戶端來測試連線(例如mysql)。可能用於測試端口,如果是問題的話telnet請跟進。iptables我不知道如何在 Windows 上做同樣的事情。我已使用相同的憑證使用 SQL Server Management Studio Express 進行驗證?我打了一個問號,因為我有點不確定資料來源的一部分(應該是主機/伺服器識別碼)。我不認為 telnet 會測試端口,因為 Windows 防火牆在 L7 上運行(它檢查應用程式)。如何確定問題是否出在我連接伺服器的能力?或定義如何連接到伺服器的配置? (注意:安全性與我無關,該虛擬機僅用於開發目的,位於我的筆記型電腦防火牆後面並且沒有 NAT)

答案1

問題出在我的配置。我最終對其進行了故障排除sqlcmd.exe,這允許我嘗試使用我指定的參數手動連接,但它們不起作用。一看它的文檔我意識到這localhost可能還不夠。我需要包括instance文檔中提到的-S [protocol:]server[\instance_name][,port]。將其添加到sqlcmd字串和 xml 配置中解決了我的連接問題。

相關內容