错误:“在建立con时发生了与网络相关或特定于实例的错误". [英] Error:"A network-related or instance-specific error occurred while establishing a con"

查看:110
本文介绍了错误:“在建立con时发生了与网络相关或特定于实例的错误".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在开发一个VB.net应用程序..当我尝试连接到数据库时,出现此错误;有很多解决方案,但对我来说效果不佳..有任何想法吗?

建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

Hi I''m developing a VB.net application .. and when I try to connect to the databse I get this error; Itry many solution but nothing is working well with me ..Any Idea?

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

推荐答案

可能是您的连接字符串有问题.
首先,尝试使用服务器资源管理器"窗格在VS中建立连接:
1)打开服务器资源管理器.
2)右键单击数据连接",然后选择添加连接"
3)在随后的对话框中,选择您的数据源和数据库,指定安全信息,然后按测试连接"按钮.
4)连接正常后,按确定"
5)在服务器资源管理器"窗格中突出显示您的数据库,然后查看属性"窗格.将显示一个连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中.

您的连接现在应该可以正常工作.
Probably, you have a problem with your connection string.
First off, 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.

Your connection should now work.


您尚未创建SQL Server实例(管理工作室),请先完成安装,然后再进行连接.正在与数据库建立联系?您可以发布您的代码吗,所以我可以给您确切的想法.:-)
You havn''t created a instance of SQL server (management studio),first complete your installation and then go for connection .if its their then, how you are making connection with Database ?can u post your code.so i can give you exact idea.:-)


按照solution-2中的讨论,
连接字符串错误.

sql连接字符串应如下所示,

如果sql server具有 Windows身份验证模式
as per discussion in solution-2,
connection string is wrong.

sql connection string should be like below,

if sql server have Windows authentication Mode
"data source=ServerName; Initial Catalog=DatabaseName; Integrated security=true;"



如果sql server具有 SQL身份验证模式



if sql server have SQL authentication Mode

"data source=ServerName; Initial Catalog=DatabaseName; Uid=SQLServerLoginId;pwd=SQLServerPassword;"



祝您编码愉快!
:)



Happy Coding!
:)


这篇关于错误:“在建立con时发生了与网络相关或特定于实例的错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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