zoukankan      html  css  js  c++  java
  • QSqlQuery query & void QSqlQuery::clear ()

    在Qt中使用sqlite数据库。

    使用QSqlQuery query执行sql语句。

    sql语句正常,但query.exec() 返回false,无法更新数据库。

    解决方法:

    使用 void QSqlQuery::clear ()

    使用query之后要query.clear()。

    View Code
     1 query.prepare("update clock set "
     2                   " title = ?,"
     3                   " remark = ?,"
     4                   " templatetype = ?,"
     5                   " looptype = ?,"
     6                   " alarmtime = ?,"
     7                   " nextalarmtime = ?,"
     8                   " onalarmtime = ?,"
     9                   " prealarmtime = ?,"
    10                   " isenable = ?"
    11                   " where id = ?");
    12 
    13     query.addBindValue(title);
    14     query.addBindValue(remark);
    15     query.addBindValue(templatetype);
    16     query.addBindValue(looptype);
    17     query.addBindValue(alarmTime);
    18     query.addBindValue(nextAlarmTime);
    19     query.addBindValue(onAlarmTime);
    20     query.addBindValue(preAlarmTime);
    21     query.addBindValue(isEnable);
    22     query.addBindValue(id);
    23     bool isSucceed = query.exec();
    24     ...
    25    query.clear();
  • 相关阅读:
    webpack的安装与配置
    npm初始化
    gitignore的配置
    git本地已有文件夹和远程仓库对应
    git 配置
    开发环境和开发工具
    git 码云使用教程
    递归
    LeetCode 392. 判断子序列
    MongoDB基本操作
  • 原文地址:https://www.cnblogs.com/lzihua/p/2619025.html
Copyright © 2011-2022 走看看