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

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

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

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


当前回答

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

其他回答

我把安装Windows 7的工作笔记本电脑换成了安装Windows 10的工作笔记本电脑。 我已经在Windows 7上成功使用了SSMS2016。

使用SSMS2012或SSMS2016时也出现了同样的问题。 我使用windows身份验证访问10个SQL服务器的权限仍然相同。我可以在另一个服务器上测试。 但是,10个服务器中的2个无法从我的笔记本电脑连接。 两者都是ms SQL server 9,但我可以连接到另一个SQL server 9数据库。

解决方案是添加防火墙规则(使用带高级安全的Windows防火墙)。

为每个SSMS创建一个Incoming规则 例如C:\Program Files (x86)\Microsoft SQL Server\130\Tools\ bin \ManagementStudio\ sssm .exe

我不是网络专家,所以我没有包括细节,但希望它能给你指明正确的方向。


错误信息msg (pre防火墙规则) "在建立与SQL Server的连接时,发生了与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确,SQL Server是否配置为允许远程连接。(提供者:SQL网络接口,错误:26 -错误定位指定的服务器/实例)(。Net SqlClient数据提供程序

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

我使用的是SQL Server 2016和windows 10。

首先是允许远程连接到SQL Server。 我所做的就是键入sqlservermanager13。在开始菜单打开SQL Server配置管理器。确保TCP/IP状态为启用状态。

双击TCP/IP协议名称,检查TCP端口号。通常默认值是1433。

以下步骤通过使用Microsoft管理控制台(MMC)管理单元配置Windows防火墙的高级安全。高级安全Windows防火墙只配置当前配置文件。

To open a port in the Windows firewall for TCP access On the Start menu, click Run, type WF.msc, and then click OK. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane. In the Rule Type dialog box, select Port, and then click Next. In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine, such as 1433 for the default instance. Click Next. In the Action dialog box, select Allow the connection, and then click Next. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next. In the Name dialog box, type a name and description for this rule, and then click Finish.

另一个需要配置的东西。

To open access to SQL Server when using dynamic ports On the Start menu, click Run, type WF.msc, and then click OK. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane. In the Rule Type dialog box, select Program, and then click Next. In the Program dialog box, select This program path. Click Browse, and navigate to the instance of SQL Server that you want to access through the firewall, and then click Open. By default, SQL Server is at C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\Sqlservr.exe. Click Next. In the Action dialog box, select Allow the connection, and then click Next. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next. In the Name dialog box, type a name and description for this rule, and then click Finish.

看看微软的文档 配置Windows防火墙访问数据库引擎

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

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

如果您正在移除迁移,您应该检查ConnectionString。