Results 1 to 3 of 3

Thread: Sql select table query error

  1. #1
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Sql select table query error

    Hello friends i have a small problem in retrieving data from a sql database. I am able to save data into the table and even retrieve it in other parts of my program. But in this place i am having a sql error .

    Qt Code:
    1. for(int i=0; i <dbrowcount.count();i++)
    2. {
    3. if((dbrowcount.at(i)>0)&&(dbrowcount.at(i)<33))
    4. {
    5. deletenum = dbrowcount.at(i);
    6. QSqlQuery sqp("SELECT Box1 FROM tempBulkdb rowid ="+ QString::number(deletenum));
    7. if(sqp.exec())
    8. {
    9. if (sqp.first())
    10. {
    11. do
    12. {
    13. boxtempchn.push_back(sqp.value(0).toString());
    14. } while(sqp.next());
    15. }
    16. }
    17.  
    18. qDebug()<< sqp.lastError().text();
    19. qDebug()<<boxtempchn;
    20. }
    To copy to clipboard, switch view to plain text mode 
    dbrowcount has the row number and the size of the list. I have 10 nested else if condition i have put only the first condition , i am testing the first condition only now.
    i get a sql error. I don't know if i am doing any thing wrong.
    This is the Sql Error i am getting.
    Qt Code:
    1. No query Unable to fetch row
    To copy to clipboard, switch view to plain text mode 

    thank you

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Sql select table query error

    I think you are missing WHERE in this following query:
    QSqlQuery sqp("SELECT Box1 FROM tempBulkdb WHERE rowid ="+ QString::number(deletenum));

  3. The following user says thank you to stampede for this useful post:

    nagabathula (4th July 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Sql select table query error

    hello thank you so much. .. that was exactly the problem. I missed the WHERE clause. It works now.
    Thank you

Similar Threads

  1. QSqlQuery and non-sql query
    By zygmunt in forum Qt Programming
    Replies: 6
    Last Post: 19th January 2011, 18:44
  2. SQL query
    By JD2000 in forum Newbie
    Replies: 4
    Last Post: 1st December 2009, 14:21
  3. MS SQL Query
    By baray98 in forum General Programming
    Replies: 0
    Last Post: 14th July 2009, 04:25
  4. Error executing SELECT query with QSQLITE
    By garfield85 in forum Qt Programming
    Replies: 6
    Last Post: 25th May 2009, 18:05

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.