簡體   English   中英

SQL錯誤:錯誤:40-無法打開與SQL Server的連接

[英]SQL Error : error: 40 - Could not open a connection to SQL Server

每當我嘗試啟動aspx頁面時,都會收到此錯誤消息。

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

在此連接字符串中連接了哪個

SqlConnection conn = new SqlConnection("Data Source=192.168.xxx.xxx;Initial Catalog=DBSample;User ID=dev;Password=pass;Integrated Security=SSPI;"))

奇怪的是,我正在連接的服務器已經托管了一些aspx頁面。 我不知道我的連接字符串中是否缺少謝謝。 而且我知道我要連接的服務器已經允許遠程連接,因為它已經托管了一些aspx網站。 :(

謝謝!

您是否需要在連接字符串中添加實例名稱? 您是否在目標計算機上運行了SQLBrowser服務,還是必須為實例指定端口?

當數據庫在您嘗試連接的位置不存在時,您也會遇到同樣的錯誤。 是否嘗試查看成功連接的aspx頁面的連接字符串?

編輯:指定Integrated Security=SSPI意味着您將使用Windows身份驗證登錄到數據庫。 您的aspx頁面以什么用戶身份運行(檢查您的應用程序池)? 它具有登錄數據庫的權限嗎? 這也可以解釋為什么它可以在一台服務器上運行而不能在另一台服務器上運行。

您是否要通過TCP / IP連接到托管的SQL Server?

我問的原因是一些防火牆阻止了端口1433上的通信。

如果不是,那只是驗證連接字符串詳細信息並確保SQL Server Engine實際上正在運行的一種情況。

您是否曾經能夠從當前嘗試進行連接的PC上連接到該數據庫?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM