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()); } }
private void _DetectServers() { Cursor = Cursors.WaitCursor; var sie = new SQLInfoEnumerator(); cbServerName.Items.Clear(); cbServerName.Items.AddRange(sie.EnumerateSQLServers()); Cursor = Cursors.Default; }
private void buttonTest_Click(object sender, EventArgs e) { object[] databases; if (SQLInfoEnumerator.TestConnection(this.textBoxConnectionString.Text, out databases)) { buttonMysqlTest.Enabled = true; MessageBox.Show(this, "Database Connection Successful."); this.comboBoxDatabase.Items.Clear(); this.comboBoxDatabase.Items.AddRange(databases); } else { buttonMysqlTest.Enabled = false; MessageBox.Show(this, "Failed to Connect to Database"); } SaveSettingsMSSQL(); }
public List <SqlDatabaseSettings> GetSQLDatabasesSettings(string pDatabaseServerName, string pDatabaseLoginName, string pDatabasePassword) { SqlConnection connection = ConnectionManager.GeneralSqlConnection; try { connection.Open(); SQLInfoEnumerator sie = new SQLInfoEnumerator { SQLServer = pDatabaseServerName, Username = pDatabaseLoginName, Password = pDatabasePassword }; List <SqlDatabaseSettings> list = new List <SqlDatabaseSettings>(); foreach (string database in sie.EnumerateSQLServersDatabases()) { SqlDatabaseSettings sqlDatabase = _GetDatabaseInfos(database, connection); if (sqlDatabase == null) { continue; } list.Add(sqlDatabase); } connection.Close(); List <string> filter = TechnicalSettings.AvailableDatabases; return(list.FindAll(db => 0 == filter.Count || filter.Contains(db.Name))); } catch (Exception) { connection.Close(); throw; } }
private void _DetectServers() { Cursor = Cursors.WaitCursor; var sie = new SQLInfoEnumerator(); cbServerName.Items.Clear(); cbServerName.Items.AddRange(sie.EnumerateSQLServers()); Cursor = Cursors.Default; }
private void FormMSSQLConnectionString() { textBoxConnectionString.Text = SQLInfoEnumerator.BuildConnectionstring(comboBoxServerName.Text, comboBoxDatabase.Text, comboBoxUserName.Text, textBoxPassword.Text, ((KeyValuePair)comboBoxAuthentication.SelectedItem).BoolValue); }