查找当地的联播网,所有SQL Server实例 [英] Find all SQL Server instances on local nework

查看:130
本文介绍了查找当地的联播网,所有SQL Server实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得所有可用的SQL Server用自己的实例名称来命名,我能找到一个本地局域网上所有可用的SQL Server的名字,但我无法找到某些SQL Server上的实例名

I am trying to get all available SQL Server to name with their instance name, I am able to find all available SQL Server names on a local LAN but I am unable to find their instance names on some SQL Server

我需要SQL Server实例名称,因为某些服务器的默认实例和某些服务器的特定实例的名称,如 pcname\sqlexpress

I need SQL Server instance name because some servers have default instance and some servers have specific instance names like pcname\sqlexpress

我这个代码来获取所有SQL Server实例。

I am this code to get all SQL Server instances ..

 DataTable dt = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources();

和我得到这些结果..

and I am getting these results ..

推荐答案

有很多的原因,这个调用会失败的全部或部分。

There are lots of reasons why this call would fail in full or partially.

从MSDN

该列表可以取决于各种因素,如超时和网络流量变化。这可能会导致该列表,以在两个连续呼叫的不同。在同一网络上的服务器才将上市。广播数据包通常不会穿过路由器,这就是为什么你可能看不到服务器上市,但它会在调用稳定。
所列服务器可以或可以不具有附加信息,诸如IsClustered和版本。这依赖于如何获得的列表。通过SQL Server Browser服务列出的服务器会比那些通过Windows的基础设施,这将只列出名称中的更多细节。

The list can vary depending on factors such as timeouts and network traffic. This can cause the list to be different on two consecutive calls. Only servers on the same network will be listed. Broadcast packets typically won't traverse routers, which is why you may not see a server listed, but it will be stable across calls. Listed servers may or may not have additional information such as IsClustered and version. This is dependent on how the list was obtained. Servers listed through the SQL Server browser service will have more details than those found through the Windows infrastructure, which will list only the name.

服务器枚举仅在运行时可用完全信任。在部分可信的环境中运行的组件将不能使用它,即使它们具有的SqlClientPermission代码访问安全性(CAS)的权限。
SQL Server提供了通过使用名为SQL浏览器外部Windows服务的SqlDataSourceEnumerator信息。此服务是默认启用的,但管理员可以将其关闭或禁用它,使服务器实例无形此类。

Server enumeration is only available when running in full-trust. Assemblies running in a partially-trusted environment will not be able to use it, even if they have the SqlClientPermission Code Access Security (CAS) permission. SQL Server provides information for the SqlDataSourceEnumerator through the use of an external Windows service named SQL Browser. This service is enabled by default, but administrators may turn it off or disable it, making the server instance invisible to this class.

由于@Orlando指出,这可能会给你一些解决方案:

As @Orlando notes this may give you some solutions:

查找的SQL Server的所有实例编程

这篇关于查找当地的联播网,所有SQL Server实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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