Is there any other reason why QSqlQuery::size() returns -1?
int QSqlQuery::size () const
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or if the database does not support reporting information about query sizes. Note that for non-SELECT statements (isSelect() returns false), size() will return -1. If the query is not active (isActive() returns false), -1 is returned. --from Qt Assistant 4.3.0 Open Source Edition
According to the assistant, QSqlQuery::size() returns -1 when isSelect() or isActive() returns false.
I made a program which uses sqlite, but it doesn't work.
I did debugging and found that when I call size(), it returns -1.
So, I checked what is returned by isSelect() and isActive() like next code, and I have very weired result.
code : qDebug() << q.size() << q.isActive() << q.isSelect();
result : warning: -1 true true
Though isActive() and isSelect() return true, size() returns -1.
Are there other reasons size() returns -1? or Is this just Qt's bug?
Re: Is there any other reason why QSqlQuery::size() returns -1?
Can you show us the complete code related to the query?
Re: Is there any other reason why QSqlQuery::size() returns -1?
What does QSqlDriver::hasFeature() return for QSqlDriver::QuerySize?
Re: Is there any other reason why QSqlQuery::size() returns -1?
Quote:
Originally Posted by
jacek
It returns false, thus QSqlQuery::size() returns -1 as the database does not support reporting information about query sizes.
Re: Is there any other reason why QSqlQuery::size() returns -1?
I checked hasFeature(), and it retuned false.
Apparently, Qt's driver for sqlite does not support size().
thank you very much, and sorry for late.