开发者

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

开发者 https://www.devze.com 2023-02-18 20:01 出处:网络
I\'m wondering does 开发者_运维百科QtSql + Sqlite support QSqlQuery::size() function?No, it doesn\'t. However, you can use last() and at() together to get the result.

I'm wondering does 开发者_运维百科QtSql + Sqlite support QSqlQuery::size() function?


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;


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消