使用C#連結MySQL並且列出指定DB內的所有資料表名稱
使用C#連結MySQL並且列出指定DB內的所有資料表名稱
資料來源: http://roboardgod.blogspot.tw/2013/08/cmysql.html
http://dev.mysql.com/downloads/connector/net/6.6.html
http://stackoverflow.com/questions/14251639/how-to-get-liststring-of-table-names-from-mysql-db
https://www.connectionstrings.com/mysql/
using System; using System.Collections.Generic; using System.Linq; using System.Text; using MySql.Data.MySqlClient; namespace CS_Console_MySQL { static void Pause() { Console.Write(“Press any key Console.ReadKey(true); } static void Main(string[] args) { string dbHost = string dbUser = string dbPass = string dbName = string connStr = MySqlConnection conn = new /* MySqlCommand command = conn.CreateCommand(); */ conn.Open(); string query = “show tables List<string> QueryResult = MySqlCommand cmdName = new MySqlDataReader reader = while (reader.Read()) { } reader.Close(); /* String account; String password; int level; for (int i = 0; i < 10; i++) { account = “account” + password = level = i * 10; command.CommandText = command.ExecuteNonQuery(); } Console.ReadLine(); */ conn.Close(); Pause(); } } |