Named Pipes Provider, error: 40 - Could not open a connection to SQL Server


Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

一、問題詳述:

{"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)"}


二、解決方法:

        從網上看了很多資料,按照其中一些步驟試了下,我主要做了以下幾處修改。

        1、開啓TCP/IP:
        開始--所有程序--SQL Server Configuration Manager--SQL Server Network Configuration--TCP/IP改爲Enabled--重啓SQL Server服務使改動生效。

        2、開通1433端口:
        Control Panle--Windows Firewall--Advanced settings--Inbound Rules--New Rule--選Port--TCP--Specific local ports設爲:1433--可命名爲SQL,繼續直到完成。

        3、修改代碼中服務器名:
        項目--App.config--將connectionString="Data Source=.;Initial Catalog=···"中加粗部分修改爲Data Source=.\SQLEXPRESS;

        做到這裏後運行,拋出異常,不過提示變爲“無法打開登錄所請求數據庫”,解決方法可參考上一篇文章。因每人遇到的情況不一樣,僅供大家參考,希望大家都能儘快解決問題。

        參考資料:重要參考



















發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章