Enumerate available SQL Servers from .Net
Anyone know if there is a more "up to date" way of enumerating all available SQL Server instances via .Net, i.e. without using System.Data - DataTable/DataRow bits.
SqlDataSourceEnumerator sqlEnumerator = SqlDataSourceEnumerator.Instance;
DataTable dt = sqlEnumerator.GetDataSources();
foreach(DataRow row in dt.Rows)
{
Console.WriteLine(row["ServerName"]开发者_JAVA百科);
Console.WriteLine(row["InstanceName"]);
Console.WriteLine("*******************************");
}
You can find several answers here.
精彩评论