从C#.Net与SQL Server命名实例连接时出错 [英] Error while connecting with SQL Server named instance from C# .Net

查看:136
本文介绍了从C#.Net与SQL Server命名实例连接时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我面临一个奇怪的问题.我有一个名为实例的sql服务器(例如(server_name)\(instance_name)).我能够使用下面的连接字符串"Data Source = ServerName; Initial Catalog = DatabaseName; Trusted_Connection = True"连接来创建SQLConnection. 如果我要连接到没有实例名称的服务器.但是,如果我尝试连接到命名实例,则trhis连接字符串将失败.我收到以下错误消息.

I am facing a strange issue. I have a sql server named instance (for example (server_name)\(instance_name)). I am able to connect to create a SQLConnection using below connection string "Data Source=ServerName;Initial Catalog=DatabaseName;Trusted_Connection=True" if I am connecting to a server without instance name. But trhis connection string fails if I try to connect to named instance. I am receiving below error.

"建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且将SQL Server配置为允许远程连接."

"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."

尽管我能够使用系统中的SSMS连接到该实例.

Though I am able to connect to that instance using SSMS from my system.

即使我尝试使用SQLConnectionStringBuilder作为连接字符串.但是我仍然收到此错误.

Even I tried to use SQLConnectionStringBuilder for for the connection string. But I am still receiving this error.

请帮助我解决此问题.

推荐答案

你好,

请参见 以下文章,请跳至为什么无法连接到SQL Server";关于命名实例.

See the following article, skip down to "Why you Can't Connect to SQL-Server" in regards to named instance.


这篇关于从C#.Net与SQL Server命名实例连接时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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