在C#中获取网络上所有sql server实例的列表 [英] Getting list of all sql server instances on the network in C#

查看:363
本文介绍了在C#中获取网络上所有sql server实例的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,



为了获取我使用以下代码的sql server实例列表。

Dear Experts,

For getting the list of sql servers instances on the i am using the below code.

SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; 
public DataTable GetInstances()
        {
           
       DataTable dtInstancesList = new DataTable();
       dtInstancesList = instance.GetDataSources().Select("", "ServerName ASC").CopyToDataTable();
            
        return dtInstancesList;
        }



我收到服务器列表,工作正常。

但这里的问题是,

在我的网络中,我们有两个域名,如A和B.



1.如果我在域A中运行此代码:

我正在获取SQL服务器实例的完整列表。

例如这里我得到的数量是100



2.如果我运行域B中的相同代码:

我没有获得SQl服务器实例的完整列表。

例如这里我的数量是10



为什么会这样,请告诉我解决方案。


I am getting the server list, its working fine.
But the problem here is,
In my network we are having two domains like A and B.

1. If i run this code in Domain A:
I am getting full list of SQL server instances.
for example here i am getting count is 100

2. If i run the same code in Domain B:
I am not getting the full list of SQl server instances.
for example here i am getting count is 10

Why this is happening, please let me know the solution.

推荐答案

阅读本文 [ ^ ]



请尝试阅读以上有关完全信任,网络流量以及导致您可能无法获得所有实例的其他因素的上述内容。
Read This[^]

Try reading the above about full trust, network traffic, and other factors that lead to why you may not get all the instances.


这篇关于在C#中获取网络上所有sql server实例的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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