Hi all,
I am trying to get a list of all the available sql servers and then populate them in a combo box. I do this with the following code taken from http://www.csharphelp.com/archives2/archive342.html
SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers();
for (int i = 0; i < sqlServers.Count; i++)
{
object srv = sqlServers.Item(i + 1);
if (srv != null)
{
this.cmbServers.Items.Add(srv);
}
}
if (this.cmbServers.Items.Count > 0)
{
this.cmbServers.SelectedIndex = 0;
}
else
{
this.cmbServers.Text = "<No available SQL Servers>";
}
However, I have a little problem. The above code retrieves a list of all the available servers, but for the local server it returns "(local)".
So, I get the Item (local) instead of the servername of my local server in the Combo Box. I need to get the servername entry in stead of "(local)"
How do I get that??
Many thanks.