Home All Groups Group Topic Archive Search About

SQL DMO Lists files severs too

Author
20 Jul 2006 4:46 PM
kj
I am using SQL DMO to list all servers on my network. The results lists
all kinds of servers not just SQL Server. It lists file servers and
some more items that I am not even aware of.
Please help!

This is my code for listing servers:

private SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
        SQLDMO.NameList sqlServers = null;


    try
            {
                //get all available SQL Servers


                sqlServers = sqlApp.ListAvailableSQLServers();
                for (int i = 0; i < sqlServers.Count; i++)
                {
                    object srv = sqlServers.Item(i + 1);
                    if (srv != null)
                    {
                        this.comboBox1.Items.Add(srv);
                    }
                }
                if (this.comboBox1.Items.Count > 0)
                    this.comboBox1.SelectedIndex = 0;
                else
                    this.comboBox1.Text = "<No available SQL Servers>";

            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }

I appreciate any help

AddThis Social Bookmark Button