internal ServerConfig GetServerConfig() { ServerConfig sc = new ServerConfig(); sc.name = name.Text; sc.host = host.Text; sc.uid = uid.Text; sc.pwd = pwd.Text; return sc; }
private void LoadServers() { servers.Clear(); serverList.Items.Clear(); try { if (!File.Exists(@"\My Documents\MobileExplorer.dat")) return; StreamReader sr = new StreamReader(@"\My Documents\MobileExplorer.dat"); string line = sr.ReadLine(); while (line != null) { string[] parts = line.Split('|'); ServerConfig sc = new ServerConfig(); sc.name = parts[0]; sc.host = parts[1]; sc.uid = parts[2]; sc.pwd = parts[3]; servers.Add(sc); serverList.Items.Add(sc.name); line = sr.ReadLine(); } sr.Close(); } catch (Exception ex) { } }
private void serverConnect_Click(object sender, System.EventArgs e) { activeConfig = (ServerConfig)servers[serverList.SelectedIndex]; server.ConnectionString = "server=" + activeConfig.host + ";uid=" + activeConfig.uid + ";pwd=" + activeConfig.pwd + ";pooling=false;database=mysql"; MessageBox.Show(server.ConnectionString, "connstr"); objectList.Items.Clear(); activeServer.Text = activeConfig.name; try { server.Open(); MySqlCommand cmd = new MySqlCommand("SHOW DATABASES", server); using (MySqlDataReader reader = cmd.ExecuteReader()) { dbList.Items.Clear(); while (reader.Read()) { dbList.Items.Add(reader.GetString(0)); } } } catch (MySqlException ex) { MessageBox.Show(ex.Message); } showServerPanel.BringToFront(); }