Example #1
0
        public bool LoadServers(bool registeredOnly)
        {
            // Get the data source enumerator object.
            bool isOk = true;

            System.Data.Sql.SqlDataSourceEnumerator serversEnum = System.Data.Sql.SqlDataSourceEnumerator.Instance;

            // Get the data sources and fill the list view.
            try
            {
                if (!registeredOnly)
                {
                    // Get data sources.
                    using (DataTable servers = serversEnum.GetDataSources())
                    {
                        // Process each row and populate the list view.
                        foreach (DataRow row in servers.Rows)
                        {
                            // Check that the server is not null.
                            if (!row.IsNull("ServerName"))
                            {
                                // Construct the instance name.
                                string serverInstance = (string)row["ServerName"];
                                if (!row.IsNull("InstanceName"))
                                {
                                    serverInstance = serverInstance + @"\" + (string)row["InstanceName"];
                                }

                                // Update the list view.
                                _listView_Servers.Items.Add(serverInstance);
                            }
                        }
                    }
                }
                else
                {
                    var servers = RegisteredServer.LoadRegisteredServers(Program.gController.Repository.ConnectionString);
                    foreach (RegisteredServer item in servers)
                    {
                        _listView_Servers.Items.Add(item.FullName);
                    }
                }
            }
            catch (Exception ex)
            {
                logX.loggerX.Error("ERROR - exception raised when enumerating servers, ", ex);
                isOk = false;
            }

            return(isOk);
        }
Example #2
0
 // Registered Server handling
 public void LoadRegisteredServers()
 {
     m_RegisteredServers = RegisteredServer.LoadRegisteredServers(m_ConnectionStringBuilder.ConnectionString);
 }