带有sqlite3的QSqlQuery INSERT语句

时间:2016-10-23 13:29:25

标签: c++ qt sqlite

这个查询没有执行,我无法看到我在哪里做错了

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')"
""

1 个答案:

答案 0 :(得分:0)

解决了:

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

问题是&#34;当&#34;,因为什么时候是sql语句,所以我需要逃避

相关问题