private void ConnectionsListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBoxItem listBoxItem = (ListBoxItem)sender; DbConnectionInfo dbConnectionInfo = listBoxItem.DataContext as DbConnectionInfo; ((MainViewModel)this.DataContext).ConnectToDb(dbConnectionInfo); }
public void ConnectToDb(DbConnectionInfo dbConnectionInfo) { this.dbAccessor = new MySqlDbAccessor(); dbAccessor.Connect(dbConnectionInfo.Hostname, dbConnectionInfo.Port, dbConnectionInfo.Database, dbConnectionInfo.Username, dbConnectionInfo.Password); Tables = new ObservableCollection<string>(dbAccessor.GetTables() as List<string>); GenerateColumnTableMapping(); Columns?.Clear(); Results = null; }
public static List <DbConnectionInfo> readSettings(String filename = "") { if (String.IsNullOrEmpty(filename)) { filename = defaultConnectionsFile; } List <DbConnectionInfo> dbConnections = new List <DbConnectionInfo>(); var parser = new FileIniDataParser(); IniParser.Model.IniData data = parser.ReadFile(filename); DbConnectionInfo thisConnection; foreach (IniParser.Model.SectionData section in data.Sections) { thisConnection = new DbConnectionInfo(); IniParser.Model.KeyDataCollection keyDataCollection = section.Keys; string hostname = keyDataCollection["hostname"]; string port = keyDataCollection["port"]; string database = keyDataCollection["database"]; string username = keyDataCollection["username"]; string password = keyDataCollection["password"]; thisConnection.ConnectionName = section.SectionName; thisConnection.Hostname = hostname; thisConnection.Port = port; thisConnection.Database = database; thisConnection.Username = username; thisConnection.Password = password; dbConnections.Add(thisConnection); } return(dbConnections); }