采用ADO.NET得到网络所有数据库服务器
#region 采用ADO.NET得到网络所有数据库服务器
public static string[] GetSqlServerName()
{
SqlDataSourceEnumerator sqlServer = SqlDataSourceEnumerator.Instance;
DataTable db = sqlServer.GetDataSources();
string[] Name = new string[db.Rows.Count + 1];
Name[0] = "(Local) ";
int i = 1;
foreach (System.Data.DataRow row in db.Rows)
{
Name[i] = row["ServerName"].ToString();
i++;
}
return Name;
}
#endregion