diff options
author | emkael <emkael@tlen.pl> | 2018-10-12 20:59:25 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-10-12 20:59:25 +0200 |
commit | 74202e8d091886e703af302dff8ee59560d1f85a (patch) | |
tree | ad84ed76878b470050cf0151ed455ca9ba4968ef | |
parent | 0550305e3f1f2558588b6b87a8c1b4004437ad3b (diff) |
Listing MySQL DBs
-rw-r--r-- | kurier/Form1.Designer.cs | 1 | ||||
-rw-r--r-- | kurier/Form1.cs | 16 | ||||
-rw-r--r-- | kurier/MySQL.cs | 6 |
3 files changed, 23 insertions, 0 deletions
diff --git a/kurier/Form1.Designer.cs b/kurier/Form1.Designer.cs index 41ac97b..47549f4 100644 --- a/kurier/Form1.Designer.cs +++ b/kurier/Form1.Designer.cs @@ -49,6 +49,7 @@ // // cbDatabaseName // + this.cbDatabaseName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbDatabaseName.FormattingEnabled = true; this.cbDatabaseName.Location = new System.Drawing.Point(89, 10); this.cbDatabaseName.Name = "cbDatabaseName"; diff --git a/kurier/Form1.cs b/kurier/Form1.cs index eb6ab88..a8bd7eb 100644 --- a/kurier/Form1.cs +++ b/kurier/Form1.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; +using MySql.Data.MySqlClient; namespace kurier { @@ -29,11 +30,26 @@ namespace kurier { if (!MySQL.getConfigured()) (new MysqlSettings()).ShowDialog(); if (!MySQL.getConfigured()) this.Dispose(); + this.refreshDatabaseList(); } private void bSettings_Click(object sender, EventArgs e) { (new MysqlSettings()).ShowDialog(); + this.refreshDatabaseList(); + } + + internal void refreshDatabaseList() + { + this.cbDatabaseName.Items.Clear(); + MySQL c = new MySQL(""); + MySqlDataReader dbs = c.select("SELECT TABLE_SCHEMA FROM information_schema.COLUMNS GROUP BY TABLE_SCHEMA;"); + while (dbs.Read()) + { + this.cbDatabaseName.Items.Add(dbs.GetString(0)); + } + this.cbDatabaseName.SelectedIndex = 0; + dbs.Close(); } } } diff --git a/kurier/MySQL.cs b/kurier/MySQL.cs index cafb5c8..81a3a0b 100644 --- a/kurier/MySQL.cs +++ b/kurier/MySQL.cs @@ -61,6 +61,12 @@ namespace kurier return ""; } + public MySqlDataReader select(string query) + { + MySqlCommand comm = new MySqlCommand(query, conn); + return comm.ExecuteReader(); + } + public static string getHost() { return Properties.Settings.Default.HOST; } public static string getUser() { return Properties.Settings.Default.USER; } public static string getPass() { return Properties.Settings.Default.PASS; } |