I use following code to get all existing sql servers.
using Microsoft.SqlServer.Management.Smo;
DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
if (dt.Rows.Count > 0)
{
cmb_servers.Items.Clear();
foreach (DataRow dr in dt.Rows)
{
cmb_servers.Items.Add(dr["Name"]);
}
}
In first attempt it's not loading any servers at all but in second it is.
I know it's quite difficult to believe but it is happening, may be any unknown mistake from my side or anything else.
Any suggestions upon that?