private void GetSQLDetails(ListBox SQLListBox) { SQLInfoEnumerator sie = new SQLInfoEnumerator(); try { if (SQLListBox.Name == "listboxSQLServerDatabaseInstances") { SQLListBox.Items.Clear(); sie.SQLServer = listboxSQLServerInstances.SelectedItem.ToString(); sie.Username = textboxUserName.Text; sie.Password = textboxPassword.Text; SQLListBox.Items.AddRange(sie.EnumerateSQLServersDatabases()); } else { SQLListBox.Items.Clear(); SQLListBox.Items.AddRange(sie.EnumerateSQLServers()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void buttonConnectServer_Click(object sender, EventArgs e) { progressBarServer.Visible = true; progressBarServer.Value = 50; SQLInfoEnumerator sie = new SQLInfoEnumerator(); try { buttonConnectServer.Enabled = false; string[] listServers = sie.EnumerateSQLServers(); if (listServers != null) { progressBarServer.Value = 80; comboBoxServerName.Items.Clear(); comboBoxServerName.Items.AddRange(listServers); } progressBarServer.Value = 100; buttonConnectServer.Enabled = true; progressBarServer.Visible = false; } catch (Exception ex) { buttonConnectServer.Enabled = true; progressBarServer.Visible = false; MessageBox.Show(ex.ToString()); } }