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

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

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

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


当前回答

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

其他回答

我使用的是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防火墙访问数据库引擎

您可以测试以下方法。

a Check the connection string of the project. b Go to services and restart SQLServer Instance. c Open 'SQLServer Configuration Manager' In the left panel select 'SQLServer Network Configuration' and expanding it Select 'Protocols for MSSQLServer' In the right panel dbl click on 'TCP/IP' In the 'Protocol' tab set the 'Enabled' to 'Yes' In the 'IP Addresses' tab scroll to down In the 'IPAll' set 'TCP Port' to 1433 d Open 'Firewall with advanced security' In the right tab select 'Inbound Rules'

在中间选项卡找到“本地端口”是1433的记录,如果你找不到它,尝试用以下级别创建它

In the Start menu, click Run, type 'WF.msc', and then click OK In the left panel click the 'Windows Firewall with Advanced Security' In the right panel right-click 'Inbound Rules', and then click 'New Rule' In the Rule Type dialog box, select 'Port', and then click Next In the Protocol and Ports dialog box, select 'TCP', and select 'Specific Local Ports', and then type the port number 1433, Click Next In the Action dialog box, select Allow the connection, and then click Next In the 'Profile' dialog box, checking the Domain, Private and Public, Then click Next In the 'Name' dialog box, type 'SQL 1433 Port' and for a description write description for own. Then click Finish

Then in the middle tab double click the found item(Instance) or created item of 'SQL 1433 Port' name by you. Select 'Scope' tab in opened dialog box(SQL Server Properties) In the Local PC Go to google.com in your Browser and search 'My IP'. then copy of your 'IP' Go to the remote server and in the 'SQL Server Properties' dialog box of 'Scope' tab, in the 'Remote IP Address' select the 'These IP Addresses' option and click 'Add' button In the opened dialog box(IP Address) select 'This IP Address or Subnet' option and paste your 'IP', click OK button.

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

如果Tomcat服务器或您正在使用的任何服务器宕机,则可能发生此错误。

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

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