public void CreateTable(string Tblname, string param) { MySqlConnection connect = new MySqlConnection(conn.getConnString()); connect.Open(); MySqlCommand command = connect.CreateCommand(); command.CommandText = "CREATE TABLE" + Tblname + @"( param )"; //string createTbl; connect.Close(); }
public string[] DisplayTables(string database) { ConnString conn = new ConnString(); conn.SetDatabase(database); string query = "show tables from " + database; MySqlConnection connection = new MySqlConnection(conn.getConnString()); MySqlCommand command = new MySqlCommand(query, connection); connection.Open(); MySqlDataReader reader = command.ExecuteReader(); List <string> rowList = new List <string>(); while (reader.Read()) { rowList.Add(reader[0].ToString()); } string[] rows = new string[rowList.Count]; for (int i = 0; i < rows.Length; i++) { rows[i] = rowList.ElementAt(i); } reader.Close(); connection.Close(); return(rows); }
public string[] DisplayDBs() { MySqlConnection connection = new MySqlConnection(conn.getConnString()); 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); }
public void InsertTuple(string Tblname) { ConnString conn = new ConnString(); MySqlConnection connect = new MySqlConnection(conn.getConnString()); connect.Open(); MySqlCommand cmd = connect.CreateCommand(); cmd.CommandText = "INSERT INTO" + Tblname + "VALUES(?,?)"; cmd.Parameters.Add("?", MySqlDbType.VarChar).Value = ""; cmd.Parameters.Add("?", MySqlDbType.VarChar).Value = ""; cmd.ExecuteNonQuery(); connect.Close(); }
//public string[] DisplayTable(string database, string table) //{ // ConnString conn = new ConnString(); // conn.SetDatabase(database); // string query = "SELECT * From " + table; // MySqlConnection connection = new MySqlConnection(conn.getConnString()); // MySqlCommand command = new MySqlCommand(query, connection); // connection.Open(); // MySqlDataReader reader = command.ExecuteReader(); // List<string> rowList = new List<string>(); // while (reader.Read()) // { // rowList.Add(reader[0].ToString()); // } // string[] rows = new string[rowList.Count]; // for (int i = 0; i < rows.Length; i++) // rows[i] = rowList.ElementAt(i); // reader.Close(); // connection.Close(); // return rows; //} public void SelectTable(string database, string table) { ConnString conn = new ConnString(); conn.SetDatabase(database); MySqlConnection connection = new MySqlConnection(conn.getConnString()); connection.Open(); bool connect = true; if (connect == true) { ViewTableForm veiwTable = new ViewTableForm(table); veiwTable.Show(); } }
public void connectToDBMS() { DatabasesForm form2 = new DatabasesForm(); ConnString connect = new ConnString(); conn = new MySqlConnection(); if (connection == false) { conn.ConnectionString = connect.getConnString(); conn.Open(); connection = true; } if (connection == true) { MessageBox.Show("Connection Successful"); form2.Show(); } }
public void connectToDB(string database) { DBTablesForm form3 = new DBTablesForm(database); ConnString connect = new ConnString(); connect.SetDatabase(database); conn = new MySqlConnection(); if (connection == false) { conn.ConnectionString = connect.getConnString(); conn.Open(); connection = true; } if (connection == true) { MessageBox.Show("Connection to Database Successful"); form3.Show(); } }