0
点赞
收藏
分享

微信扫一扫

Winform中实现连接Mysql并获取所有表名


场景

Winform中连接Mysql8并查询表中数据进行显示:

​​Winform中连接Mysql8并查询表中数据进行显示_BADAO_LIUMANG_QIZHI的博客-博客​​

在上面实现连接Mysql8的基础上,怎样获取数据库中所有的表名。

Winform中实现连接Mysql并获取所有表名_c#

注:

实现

在获取所有表名的点击事件中

DataGridViewColumn checkCol = new DataGridViewCheckBoxColumn();
checkCol.Name = "选择";
this.dataGridView_show_tables_name.Columns.Add(checkCol);
DataTable tbName = mySqlConnection.GetSchema("Tables");
if (tbName.Columns.Contains("TABLE_NAME"))
{
foreach (DataRow dr in tbName.Rows)
{
tableNameList.Add((string)dr["TABLE_NAME"]);
}
}
this.dataGridView_show_tables_name.DataSource = this.tableNameList.Select(x => new { Value = x }).ToList();

其中

List<string> tableNameList = new List<string>();

举报

相关推荐

0 条评论