【问题标题】:Connector c++ res->getBoolean Acess Violation连接器 c++ rs->getBoolean 访问冲突
【发布时间】:2014-11-14 10:20:09
【问题描述】:

我在Visual Studio 2013 中使用mysql-connector-c++-1.1.4-winx64。 连接到特定数据库并读取整数值是可行的,但是无法检索任何布尔值。
我可以编译包含附加代码的程序,但程序关闭检索:

“程序 '[3480] Project1.exe: Managed (v4.0.30319)' 已退出 代码为 -1073741819 (0xc0000005) '访问冲突'。"

感谢您的帮助!

                                    const char* idQuery = "SELECT EXISTS (SELECT id FROM experiment_results WHERE id='22');";
                                    stmt = con->createStatement();
                                    stmt->execute(idQuery);
                                    while (res->next()) 
                                    {
                                        bool flag = res->getBoolean(1);
                                    }

【问题讨论】:

  • 他们的查询是空的。仔细检查它,你会发现它可能试图访问空数据。
  • 我是否需要对此进行进一步解释。 “SELECT EXISTS(Query)”不应该独立于“Query”的返回值,总是检索真或假吗?

标签: c++ mysql mysql-connector connector


【解决方案1】:

再次查看代码后,我发现了我的错误: stmt->执行(idQuery); // 应该: res = stmt->executeQuery(idQuery);

【讨论】:

    猜你喜欢
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多