问题
System.Data.SqlClient.SqlException:“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)”
----
System.Data.SqlClient。SqlException:“在建立到SQL Server的连接时,发生了与网络相关或特定于实例的错误。没有找到服务器或无法访问服务器。验证实例名是否正确,并将SQL Server配置为允许远程连接。(提供者:指定管道提供者,错误:40 -无法打开到SQL服务器的连接)”
解决方案
连接字符串 用 127.0.0.1 、localhost 和 . 点 都不行
可能是自己电脑装了多个版本的 SqlServer
得用机器名+服务名
Data Source=DESKTOP-46PCO3Q\\MSSQLSERVER2017