QtSQL + Sqlite and support for .size() function?

跟風遠走 提交于 2019-12-01 07:07:42

问题


I'm wondering does QtSql + Sqlite support QSqlQuery::size() function?


回答1:


No, it does't. SQLite is one of the databases for which the size of the query is not directly available. BTW: A Google-query for "qt sqlite QSqlQuery size" had this StackOverflow question as first answer.




回答2:


No, it doesn't. However, you can use last() and at() together to get the result.

QSqlQuery q;
q.exec("select * from table");
q.last();
qDebug() << q.at() + 1;



回答3:


I also faced the same issue with SQLite and Qt.

As a solution I used

if (query.next())
{
}

to identify the query returns values or not.

But be careful it directs you to the first record. And if you need the no of records exactly, then this is not a solution.



来源:https://stackoverflow.com/questions/5373184/qtsql-sqlite-and-support-for-size-function

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