错误:40 - 无法打开与SQL Server的连接 [英] error: 40 - Could not open a connection to SQL Server

查看:195
本文介绍了错误:40 - 无法打开与SQL Server的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请解决我的问题

错误:

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



我的电脑名称:bhargava-f794cb

Instace名称:MSSQLSERVER



什么是数据源名称

Hi,
Please solve my problem
Error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

My pcname:bhargava-f794cb
Instace name:MSSQLSERVER

what is the datasource name

SqlConnection conn = new SqlConnection("Data Source=MSSQLSERVER;Initial Catalog=OnlineLibrary;Integrated Security=True");

推荐答案

尝试使用服务器资源管理器窗格在VS中设置连接:

1)打开服务器资源管理器。

2)右键单击数据连接并选择添加连接

3)在随后出现的对话框中,选择您的数据源,和数据库,指定安全信息,然后按测试连接按钮。

4)连接工作时,按确定

5)突出显示您的数据库在服务器资源管理器窗格中,查看属性窗格即将显示连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中。
Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.


SqlConnection conn = new SqlConnection("Data Source=bhargava-f794cb\SQLEXPRESS;Initial Catalog=OnlineLibrary;Integrated Security=True");


这篇关于错误:40 - 无法打开与SQL Server的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆