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

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

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

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


当前回答

您可以检查MS SQL Server 2014的服务状态。在Windows 7中,你可以这样做:

搜索并输入“SQL Server 2014配置管理器” 然后点击左侧菜单中的“SQL Server Service” 检查SQL Server实例的服务状态是否为“stopped”或“running” 如果已停止,请将状态改为“运行中”,并登录SQL Server Management Studio 2014

其他回答

如果以上解决方案都不起作用(对我来说都不起作用),那么只需重新启动计算机,您就可以连接到sql server (localhost)。

我也有这个问题,我尝试了这篇文章中建议的所有方法,但没有任何效果。最后,我通过在SQL Server中执行这个查询解决了我的问题

EXEC sp_configure 'remote access', 0 ;  
GO  
RECONFIGURE ;  
GO  

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论坛的帖子帮助我找到了这个。

如果在Visual Studio中调试时遇到这种情况,请确保项目构建路径指向本地驱动器,或者按照以下步骤为网络文件夹授予权限。

我也遇到过同样的问题 就我而言,我用这种方法解决了问题

步骤1:从开始菜单进入SQL server配置管理器

步骤2:启用TCP/IP

步骤3:双击TCP/IP,进入IP地址最后一个条目IP ALL,输入TCP端口1433然后应用

第四步:然后按win+r,写服务。msc打开服务,然后向下滚动,然后右键单击SQL Server (MSSQLSERVER)选择重新启动

这解决了我的问题。 即使做以上所有步骤都不能解决问题,然后简单地重新启动PC,希望它会工作。