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

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

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

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


当前回答

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

其他回答

此错误主要发生在SQL服务停止时。您需要重新启动服务。要进入这个窗口,您必须像这样搜索服务-

然后搜索“SQLSERVER(MSSQLSERVER)”,并重新启动服务。

希望这能奏效。

为什么这个错误是如此烦人和嘈杂,只是因为它可以发生在不同的情况。

我已经做了上面所有的方法,但还是很糟糕。所以,在向下浏览之前,确保你和我做了同样的事情。

也许我不能立即解决你的问题,但我可以给你指明一个方向或思路(最后滑下来的那个人)。我已经开始思考我的运行程序的错误发生后,我确保实例名是明确正确的,并设置我的数据库,以允许远程控制以下的方法。之后,我怀疑我的SQL连接代码片段发生了错误。

我的问题解决方案:

检查我的sqlconnection函数

单击以查看其配置

新建连接

选择你的服务器名

对我来说,思考在联系的过程中到底发生了什么是有效的。希望我的想法能引导你改正错误。

我几乎什么都试过了。然后,我已经卸载了Malwarebytes。一种声称可以删除恶意软件的软件(通常可以)。在那之后,一切都好了。也许有人会因为同样的原因遇到同样的问题。

重启SQL Server (MSSQLSERVER)服务即可。

您可以测试以下方法。

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.