views:

43

answers:

1

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"]);
    Console.WriteLine(row["InstanceName"]);
    Console.WriteLine("*******************************");
}
+1  A: 

You can find several answers here.

Restuta
Its interesting why somebody gave me -1?
Restuta