如何在 C# 中从 MySQL 数据库获取表名列表?
最佳答案
请参阅此链接,它从连接开始进行解释
http://www.geekpedia.com/tutorial139_Connecting-to-MySQL-with-Csharp-and-ODBC.html
你需要运行“显示表格”
private void btnListTables_Click(object sender, EventArgs e)
{
if (OdbcCon.State == ConnectionState.Open)
{
// Execute the SHOW TABLES query on the MySQL database
OdbcCom = new System.Data.Odbc.OdbcCommand("SHOW TABLES", OdbcCon);
OdbcDR = OdbcCom.ExecuteReader();
txtLog.AppendText("Tables inside " + txtDatabase.Text + ":\r\n");
// Loop through the list of tables and display each one
while (OdbcDR.Read())
{
txtLog.AppendText(">> " + OdbcDR[0] + "\r\n");
}
}
}
关于c# - 如何在 C# 中从 MySQL 数据库获取表名列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5401848/