public string[] DisplayDBs() { MySqlConnection connection = new MySqlConnection(conn.GetConStr()); String query = "SHOW DATABASES;"; MySqlCommand command = new MySqlCommand(query, connection); connection.Open(); MySqlDataReader reader = command.ExecuteReader(); string[] rows = new string[reader.FieldCount]; int i = 0; while (reader.Read()) { if (i != 0) { rows[i - 1] = reader[0].ToString(); } i++; } reader.Close(); connection.Close(); return(rows); }
private void insertButton_Click(object sender, EventArgs e) { try { MySqlConnection connection = new MySqlConnection(conn.GetConStr()); connection.Open(); MySqlCommand cmd = connection.CreateCommand(); cmd.CommandText = "INSERT INTO " + table + " VALUES(" + GetInsertQueryString() + ");"; cmd.ExecuteNonQuery(); ViewTableForm tableForm = new ViewTableForm(conn, table); tableForm.Show(); this.Close(); } catch { MessageBox.Show("Invalid Entries"); } }
public void connectToDBMS(ConnString cs) { DatabasesForm form2 = new DatabasesForm(cs); ConnString connect = cs; mySqlConnection = new MySqlConnection(); if (connection == false) { mySqlConnection.ConnectionString = connect.GetConStr(); mySqlConnection.Open(); connection = true; } if (connection == true) { MessageBox.Show("Connection Successful"); form2.Show(); } }
public void SelectTable() { MySqlConnection connection = new MySqlConnection(conn.GetConStr()); connection.Open(); bool connect = true; if (connect == true) { ViewTableForm veiwTable = new ViewTableForm(conn, table); veiwTable.Show(); } }
private void executeButton_Click(object sender, EventArgs e) { string query = sqlTextBox.Text; MySqlConnection connection = new MySqlConnection(conn.GetConStr()); MySqlCommand command = new MySqlCommand(query, connection); connection.Open(); MySqlDataReader reader = command.ExecuteReader(); //string output = ""; //while (reader.Read()) //{ // foreach (object s in reader) // output += s.ToString(); // output += "\n"; //} reader.Close(); connection.Close(); //MessageBox.Show(output); }