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

Named Pipes Provider, error: 40 - Could not open a connection to SQL Server_第1张图片

二、解决方法:

        从网上看了很多资料,按照其中一些步骤试了下,我主要做了以下几处修改。

        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;

        做到这里后运行,抛出异常,不过提示变为“无法打开登录所请求数据库”,解决方法可参考上一篇文章。因每人遇到的情况不一样,仅供大家参考,希望大家都能尽快解决问题。

        参考资料:重要参考




















你可能感兴趣的:(Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)