예제 #1
0
        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);
        }
예제 #2
0
        //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();
            }
        }
예제 #3
0
        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();
            }
        }