繁体   English   中英

QSqlQuery INSERT语句与sqlite3

[英]QSqlQuery INSERT statement with sqlite3

该查询未执行,看不到我在哪里做错了

QSqlQuery query(QString("INSERT INTO [main].[sell_log] (cart_id, title, price, amount, disscount, type, total, bill_number, whos, when) "
                    "VALUES ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9', '%10')").arg(cart_id).arg(title).arg(price).arg(amount).arg(disscount)
                    .arg(type).arg(total).arg(bill_number).arg(whos).arg(when));
    qDebug() << query.lastQuery();
    qDebug() << query.executedQuery();

输出:

"INSERT INTO [main].[sell_log] (cart_id, title, price, amount, disscount, type, total, bill_number, whos, when) VALUES ('5', 'جديد', '7', '1', '0', 'سعر البيع', '7', '151', '1', '23-10-2016')"
""

解决了 :

QSqlQuery query(QString("INSERT INTO [main].[sell_log] (cart_id, title, price, amount, disscount, type, total, bill_number, whos, 'when') "

问题是“何时”,因为何时是sql语句,所以我需要转义

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM