Windows-Server-2008

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

  • September 13, 2013

我正在嘗試讓 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)

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

引用自:https://serverfault.com/questions/538538