|
using System;
using System.Data.Sql;
using System.Text;
namespace AllSqlServer
{
class Program
{
static void Main(string[] args)
{
//SQLDMO.NameList names;
//SQLDMO.ApplicationClass ac = new SQLDMO.ApplicationClass();
//names = ac.ListAvailableSQLServers();
//string[] serverList = new string[names.Count];
//for (int i = 0; i < serverList.Length; i++)
//{
// serverList[i] = names.Item(i);
//}
//foreach (string str in serverList)
//{
// Console.WriteLine(str);
//}
SqlDataSourceEnumerator instance =SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();
DisplayData(table);
Console.ReadLine();
}
private static void DisplayData(System.Data.DataTable table)
{
foreach (System.Data.DataRow row in table.Rows)
{
Console.WriteLine("服務(wù)器名 = {0}", row["ServerName"]);
Console.WriteLine("實例名 = {0}", row["InstanceName"]);
Console.WriteLine("是否集成驗證 = {0}", row["IsClustered"]);//即Windows身份驗證和SQL Server驗證
Console.WriteLine("版本 = {0}", row["Version"]);//8.*是SQL 2000,9.*是SQL 2005
Console.WriteLine("============================");
}
}
}
}
文章引用自:
AspNet技術(shù):C#列出局域網(wǎng)中可用SQL Server服務(wù)器(續(xù)),轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。