public AddNewForm(MySqlConnection _conn, MainForm _parent, string _what) { InitializeComponent(); conn = _conn; parent = _parent; what = _what; }
public SetForm(MySqlConnection _conn, MainForm _parent, string _what) { InitializeComponent(); conn = _conn; what = _what; parent = _parent; if (what == "grant") this.Text = "Grant"; if (what == "revoke") { this.Text = "Revoke"; Option.Visible = false; } Privilege.Items.Add("ALL PRIVILEGES"); Privilege.Items.Add("FILE"); Privilege.Items.Add("RELOAD"); Privilege.Items.Add("ALTER"); Privilege.Items.Add("INDEX"); Privilege.Items.Add("SELECT"); Privilege.Items.Add("CREATE"); Privilege.Items.Add("INSERT"); Privilege.Items.Add("SHUTDOWN"); Privilege.Items.Add("DELETE"); Privilege.Items.Add("PROCESS"); Privilege.Items.Add("UPDATE"); Privilege.Items.Add("DROP"); Privilege.Items.Add("REFERENCES"); Privilege.Items.Add("USAGE"); MySqlCommand command = new MySqlCommand("SHOW DATABASES", conn); MySqlDataReader what_we_got = null; try { what_we_got = command.ExecuteReader(); while (what_we_got.Read()) { DataBase.Items.Add(string.Format("{0}", what_we_got.GetString(0))); } DataBase.Items.Add("*"); } finally { if (null != what_we_got) what_we_got.Close(); } }
private void bConnect_Click(object sender, EventArgs e) { try { toolStripStatusLabel1.Text = "Connecting to server"; conn = new MySqlConnection(string.Format("server={0};port=3306;user={1};password={2};database=mysql", Host.Text, User.Text, Password.Text)); conn.Open(); MainForm mn = new MainForm(conn); mn.Show(); Hide(); } catch { conn.Close(); toolStripStatusLabel1.Text = "Wrong data"; Password.Text = ""; } }