【问题标题】:How to get MySQL Server response after query execution (C#)查询执行后如何获取 MySQL 服务器响应(C#)
【发布时间】:2018-08-01 00:34:52
【问题描述】:

我正在用 C# 开发一个程序,在该程序中我将一些插入(加载数据 infile)到 mysql 表中。每次执行后如何获得工作台显示的响应?

我对显示所有警告的“消息”列感兴趣。

谢谢!

【问题讨论】:

标签: c# mysql database mysql-workbench


【解决方案1】:

这就是我解决问题的方法...谢谢你的链接,雷蒙德。

在我执行任何语句(在我的例子中是加载数据到文件中)之后,我执行以下操作:

MySqlCommand command2 = new MySqlCommand("SHOW WARNINGS", con);
using (MySqlDataReader reader = command2.ExecuteReader())
{
    while (reader.Read())
    {
        String level = reader["Level"].ToString();
        String code = reader["Code"].ToString();
        String message = reader["Message"].ToString();
    }
}

'show warnings' 在三列中返回结果集:'Level'、'Code' 和 'Message'。这就是我获取所需数据的方式。

我希望这会有所帮助;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    • 1970-01-01
    • 2017-05-16
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多