这个查询没有执行,我看不出我在哪里做错了
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')"
""
solved:
QSqlQuery query(QString("INSERT INTO [main].[sell_log] (cart_id, title, price, amount, disscount, type, total, bill_number, whos, 'when') "
问题是"when",因为when是SQL语句,所以我需要转义