MySQL C ++ Connector UPDATE

时间:2015-01-21 19:47:25

标签: c++ mysql connector

我在使用MySQL C ++ Connector时遇到问题...我的问题是我有一个查询:UPDATE characters SET name = 'myNameIs' WHERE characregistra = 'MyguidIs' 字符是表,名称列,characregistra也是。当我在characregistra列中找到值" MyguisIs"时,我尝试将myNameIs值放入名称中。它有效,但没有try {] catch {],它崩溃了。我试图用sql :: SQLException获取错误,但是没有办法,没有任何打印... 提前谢谢。

编辑:忘了把代码:

void renameCharac(std::string guid, std::string pseudo)
{
    try{
        sql::Statement *declaration;
        declaration = connection->createStatement(); // Connection is declared
        declaration->executeQuery("UPDATE characters SET name = '" + pseudo + "' WHERE characregistra = '" + guid + "'");
        delete declaration;
    }
    catch (sql::SQLException e)
    {
        std::cout << e.what();
    }
}

1 个答案:

答案 0 :(得分:0)

最后我这样做了:

void renameCharac(std::string guid, std::string pseudo)
{
        sql::Statement *declaration;
        declaration = connection->createStatement();
        declaration->executeUpdate("UPDATE characters SET name = '" + pseudoChoisi + "' WHERE characregistra = '" + guid + "'");
        delete declaration;
}

有效。