Qt QSqlQuery bindValue works with ? but not with :placeholders

心不动则不痛 提交于 2019-12-01 16:55:33
lpapp

Please use prepare as the official example:

QSqlQuery testQuery;
testQuery.prepare("INSERT INTO test(testcol) VALUES(:val)");
testQuery.bindValue(":val", someQStringObj);
testQuery.exec();

The reason for the error is that the query was executed before binding to the corresponding placeholder. You can see the relevant part of the constructor documentation:

If query is not an empty string, it will be executed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!