当我尝试连接SQL Server时,我得到以下错误:

在建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确,SQL Server是否配置为允许远程连接。(提供商:Named Pipes提供商,错误:40 -无法打开到SQL Server的连接)

当我试图在Visual Studio 2010中将数据库配置为gridview时抛出此错误。我不知道如何调试这个错误。

如何调试此错误?除了错误消息中提到的步骤之外,我还应该采取哪些步骤来确定这里到底发生了什么?


当前回答

I had the same issue after upgrading my Windows to Windows Pro 10 21H2. I have two SQL instances - 2014 and 2019 and I was not able to connect only to 2019 one. I restarted the computer, restarted all SQL related services. Two of the services were showing errors (SQL Server and SQL Server agent) and I was not able to start them. I could not also start these two services from C:\Windows\SysWOW64\SQLServerManager15.msc In the logs (C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER01\MSSQL\Log) I saw these lines:

Initializing the FallBack certificate failed with error code: 15, state: 29, error number: 0.
Error: 17190, Severity: 16, State: 1.
Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.
Error: 17182, Severity: 16, State: 1.
TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property. 
Error: 17182, Severity: 16, State: 1.
TDSSNIClient initialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property. 
Error: 17826, Severity: 18, State: 3.
Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
Error: 17120, Severity: 16, State: 1.
SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the operating system error log for information about possible related problems.

原来在升级后,服务的“Log On”属性(服务属性上的第二个选项卡)被设置为NT AUTHORITY\NETWORK SERVICES。当我将其更改为“本地系统帐户”时,我能够启动服务并连接到MS SQL 2019实例。

这个msdn论坛的帖子帮助我找到了这个。

其他回答

我将使用Entity Framework的项目设置为启动项目,然后运行update-database命令,解决了这个问题。

这个解决方案解决了SQL服务器背后的网络错误和服务问题

我在这里回答了一个类似的问题,您需要统计其他开放运行类型->服务。msc -在服务->排序停止你会看到一堆停止的SQL服务右键单击并启动

开始-有4个问题可能会导致常见的LocalDb SqlExpress Sql Server连接错误Sql网络接口,错误:50 -本地数据库运行时错误发生,在开始之前,您需要将v11或v12重命名为(LocalDb)\mssqllocaldb


Troubleshooting Steps

您没有正在运行的服务,执行命令net start MSSQLSERVER或net start MSSQL$ instancename 这里没有防火墙端口 配置 你的安装有问题/损坏(下面的步骤可以帮助你一个干净的开始) 您没有将V11或12重命名为mssqllocaldb/SqlServer

我发现最简单的是做下面的事情——我附上了图片和步骤以寻求帮助。


Resolution Steps:

首先验证您已经安装了哪个实例,您可以通过检查注册表并运行cmd来完成此操作

i .执行命令> Sqllocaldb.exe cmd> Sqllocaldb.exe s "那个versionyouwantfromlistbefore " 如果此步骤失败,可以使用选项d删除cmd> Sqllocaldb.exe d "someDb" cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb" cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"


重新启动MSSql服务器或简单地重新启动您的机器!

按住/按打开CMD,窗口+ R,输入“services.msc” 现在寻找sql server服务,打开查找带有实例名的sql server 然后重新启动此服务并重试

I got this error after working at distance (VPN) for a few years. At some point in time I must have changed my DNS settings to the IP address of my home router. Now I was (again) in the same network as the server, and got the error above. the solution was to open "Network status" / "Change adapter options" and right click the active internet connection (Ethernet in my case) to get to the properties of IPv4. Under "Use the following DNS server addresses" I entered the local IP address of my server, and what do you know...! The computer contacted the domain (on the server) and SQL Server opened up.

要检查是否有相同的问题,打开cmd并输入 夜间电报/ dsgetdc:域名 [用域名交换"domainname"] 如果您得到一条消息说“获取DC名称失败:Status = 1355 0x54b ERROR_NO_SUCH_DOMAIN”,您可能是域名错误,或者您可能有这个问题。

我必须运行SQL Server浏览器服务到SQL Server配置管理器。 如果没有这个,安装就不能发现新创建的服务。

我的问题是,你需要在存储库层和web层都有一个连接字符串条目。有一次我把它加到我的网里。config以及我的app.config,实体框架能够创建迁移。

我的问题是,为什么网络。配置需要它,当绝对没有数据库访问那里。