有没有可能知道QSqlQuery :: bindValue调用好吗?
函数返回void,我想知道为什么?至少应该报告所需的占位符不存在(ihmo)为错误。
也许有另一种可能性来检查,绑定是否正确?
答案 0 :(得分:1)
使用bindValue()并传递占位符名称或位置,它将返回已绑定的值,因此您将能够检查值是否已正确绑定。或者使用boundValues(),它将返回所有键和值的映射:
boundValues()
QMapIterator<QString, QVariant> i(query.boundValues());
while (i.hasNext()) {
i.next();
cout << i.key().toUtf8().data() << ": "
<< i.value().toString().toUtf8().data() << endl;
}