SQLITE插入命令在Qt中显示SIGSEGV错误

时间:2016-05-07 06:32:57

标签: c++ qt sqlite

这是我的代码,显示SIGSEGV错误。但我无法找到我的错误。当我将代码完全复制到SQLite并运行它时,它可以工作。但它向我展示了Qt IDE中的SIGSEGV错误 这是我的代码:

bool DB::InsertUserAuthenticate(int id,int Admin,int Active,int AT_ID,int UI_ID,QString UA_Data)
{
    QSqlQuery q;
    //begin transaction
    /*insert data if the exact data not repeated in table*/
    q.prepare("BEGIN; INSERT INTO UserInfo(UI_ID,UI_Admin,UI_Active)"
              " SELECT :id,:admin,:active"
              " WHERE NOT EXISTS(SELECT 1 FROM UserInfo "
              " WHERE UI_ID=:id AND UI_Admin=:admin AND UI_Active=:active);"
              " INSERT INTO UserAuthenticate"
              " (AT_ID,UI_ID,UA_Data,UA_Active)"
              " VALUES (:atid,:uiid,:uadata,:active);"
              "COMMIT;");
             /* " VALUES (:id,:admin,:active);");*/
    q.bindValue(":id", id);
    q.bindValue(":admin", Admin);
    q.bindValue(":active", Active);
    q.bindValue(":atid", AT_ID);
    q.bindValue(":uiid",UI_ID);
    q.bindValue(":uadata",UA_Data);

    if(q.exec())
    {
        q.exec("COMMIT;");//finished the transaction
        return true;
    }
    else
    {
        q.exec("ROLLBACK;");//bad finished. should rool back
        msg=q.lastError().text();
    }
    return false;
}

0 个答案:

没有答案