+ Reply to Thread
Results 1 to 5 of 5

Thread: Is there any other reason why QSqlQuery::size() returns -1?

  1. #1
    Join Date
    Apr 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,499
    Thanks
    3
    Thanked 4,730 Times in 4,529 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Is there any other reason why QSqlQuery::size() returns -1?

    Can you show us the complete code related to the query?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 973 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there any other reason why QSqlQuery::size() returns -1?

    What does QSqlDriver::hasFeature() return for QSqlDriver::QuerySize?

  4. #4
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there any other reason why QSqlQuery::size() returns -1?

    Quote Originally Posted by jacek View Post
    What does QSqlDriver::hasFeature() return for QSqlDriver::QuerySize?
    It returns false, thus QSqlQuery::size() returns -1 as the database does not support reporting information about query sizes.

  5. #5
    Join Date
    Apr 2007
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts