コード例 #1
0
        private void UpdateUIOnDatabaseSelected()
        {
            try
            {
                if (DatabaseComboBox.SelectedItem == null)
                {
                    MessageBox.Show("You have to select database to use first", "Mu Editor");
                    return;
                }

                var     parser = new FileIniDataParser();
                IniData data   = new IniData();
                data = parser.ReadFile("db.ini");
                KeyDataCollection keyCol = data[DatabaseComboBox.SelectedItem.ToString()];
                DbModel.Connect(GenerateConnectionString(keyCol["mainHost"], keyCol["mainCatalog"], keyCol["mainUsername"],
                                                         keyCol["mainPassword"]), GenerateConnectionString(keyCol["userHost"], keyCol["userCatalog"], keyCol["userUsername"],
                                                                                                           keyCol["userPassword"]));
                updated = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Could not connect to database OR open ini file (Look in exception)\n[Exception]\n" + ex.Message,
                    "Mu Editor");
                updated = false;
            }
        }