Below code works for me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
namespace CP_329450_this_Csharp_program_is_not_showing_any_output_why
{
class Program
{
static void Main()
{
SqlDataSourceEnumerator instance =
SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();
DisplayData(table);
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
private static void DisplayData(System.Data.DataTable table)
{
foreach (System.Data.DataRow row in table.Rows)
{
foreach (System.Data.DataColumn col in table.Columns)
{
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
}
Console.WriteLine("============================");
}
}
}
}
But will useally take time to browse all sql server instances.
You can try :
1) start import / export wizard
2) try to drop down source connection combo box.
3) and see how much time it will take. The same time above code will take.
If you debug you will know it will halt at
System.Data.DataTable table = instance.GetDataSources();
this line.
Hope this helps if yes then accept and vote the answer
--Rahul D.