列出所有数据库服务器 [英] List all database servers
本文介绍了列出所有数据库服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨。
我正在制作一个窗体应用程序,它返回服务器中的所有数据库。
我让它运行带有SMO的SQL服务器,但我不想仅限于SQL服务器。
我想显示所有可用的数据库服务器(本地和网络)。
无论如何,我可以列出所有可用的数据库服务器,SQL,ODBC,......?
所以我可以选择我想要使用的服务器并显示其中的所有数据库吗?
谢谢。
Hi.
I'm making a windows form application that returns all databases in a Server.
I have it running for SQL servers with SMO, but i don't want to limit only for SQL servers.
I want to show all db servers (local and network) available.
Is there anyway that i can list all available database servers, SQL, ODBC, ...?
So i can choose the server that i want to work with and show all databases available in it?
Thanks.
推荐答案
尝试:
Try:
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
DataTable dt = instance.GetDataSources();
foreach (System.Data.DataRow row in dt.Rows)
{
Console.WriteLine("ServerName = {0}", row["ServerName"]);
}
SMO中的
我发现这个
in SMO i find this
DataTable dtServers = SmoApplication.EnumAvailableSqlServers();
并且工作正常。
thk for your help
and work perfectly.
thk for your help
这篇关于列出所有数据库服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文