Пример #1
0
        private void GetServerList()
        {
            DataTable dt;

            // Set local server as default
            dt = SmoApplication.EnumAvailableSqlServers(false);
            if (dt.Rows.Count > 0)
            {
                // Load server names into combo box
                foreach (DataRow dr in dt.Rows)
                {
                    ServerNamesComboBox.Items.Add(dr["Name"]);
                }

                // Default to this machine
                ServerNamesComboBox.SelectedIndex
                    = ServerNamesComboBox.FindStringExact(
                          System.Environment.MachineName);

                // If this machine is not a SQL server
                // then select the first server in the list
                if (ServerNamesComboBox.SelectedIndex < 0)
                {
                    ServerNamesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                Logger.LogError("", new Exception("No servers found"));
            }
        }
Пример #2
0
        private void GetServerList()
        {
            DataTable dt;

            // Set local server as default
            dt = SmoApplication.EnumAvailableSqlServers(false);
            if (dt.Rows.Count > 0)
            {
                // Load server names into combo box
                foreach (DataRow dr in dt.Rows)
                {
                    ServerNamesComboBox.Items.Add(dr["Name"]);
                }

                // Default to this machine
                ServerNamesComboBox.SelectedIndex
                    = ServerNamesComboBox.FindStringExact(
                          System.Environment.MachineName);

                // If this machine is not a SQL server
                // then select the first server in the list
                if (ServerNamesComboBox.SelectedIndex < 0)
                {
                    ServerNamesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                ExceptionMessageBox emb = new ExceptionMessageBox();
                emb.Text = Properties.Resources.NoSqlServers;
                emb.Show(this);
            }
        }
        private void GetServerList()
        {
            DataTable dt;

            // Set local server as default
            dt = SmoApplication.EnumAvailableSqlServers(false);
            if (dt.Rows.Count > 0)
            {
                // Load server names into combo box
                foreach (DataRow dr in dt.Rows)
                {
                    ServerNamesComboBox.Items.Add(dr["Name"]);
                }

                // Default to this machine
                ServerNamesComboBox.SelectedIndex = ServerNamesComboBox.FindStringExact(System.Environment.MachineName);

                // If this machine is not a SQL server
                // then select the first server in the list
                if (ServerNamesComboBox.SelectedIndex < 0)
                {
                    ServerNamesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(Properties.Resources.NoSqlServers, Properties.Resources.Error2, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }