Results 1 to 6 of 6

Thread: Query Size needed

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Query Size needed

    background:

    I am using QOBDC driver on my windows application and it is connected on MS SQL database.

    My woe:

    I use QTableView with QSqlTableModel to display the result of my query and I want to display the number of records returned from my query. When i use QSqlQuery::size() it will only give me -1 and if I use QSqlTableModel::rowCount() it will only give the rows in model's cache.

    It seems like my driver doesn't support QSqlDriver::QuerySize, Is there any other way?

    is there a QOBDC driver thats support query size?

    baray98

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Query Size needed

    If your driver does not support this, you can first execute a query selection "count(1)" for your query. Obviously, this is not as fast as if the driver or database could do that...

    HTH

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Query Size needed

    pardon my being newbie but can you elaborate on "execute count(1)" thingy I don't understand

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Query Size needed

    It's about asking the database to return the number of rows in the table.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Query Size needed

    I don't think this is an easy task since my user will input the SQL statement and then i will display the result in a table. and the number of records return would be at the bottom

    Is there any other way of knowing the sqlresult size?

    Is there anything i should in MS SQL to support sqlresult size?

    baray98

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Query Size needed

    parse the string with the query and replace the content between SELECT and FROM with count(1), then you will get the number of rows for that particular query.

Similar Threads

  1. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 16:13
  2. Text size
    By bnilsson in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2008, 21:56
  3. How to find best size for QTableWidget?
    By plamkata in forum Qt Programming
    Replies: 3
    Last Post: 24th July 2008, 19:07
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.