Results 1 to 4 of 4

Thread: problem with SELECT NEXTVAL

  1. #1
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default problem with SELECT NEXTVAL

    Hello!

    I would need to carry out a SELECT NEXTVAL but its does not work. Here is the code.

    Qt Code:
    1. query.exec("SELECT NEXTVAL(\'mytable\');")
    2. query.next();
    3. cout << query.value(0).toInt() << "\n";
    To copy to clipboard, switch view to plain text mode 

    I obtain an error message saying that I am not on a valid record. Indeed, query.next() and query.exec("...") return false but with a lastError().text() empty. The function query.isSelect() also returns false.

    What can I do?

    Thanks!

  2. #2
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with SELECT NEXTVAL

    What database type are you using?

    I would use query.last() (not query.next())
    That positions you on the query you just executed.

  3. #3
    Join Date
    Nov 2009
    Posts
    29
    Thanks
    10

    Default Re: problem with SELECT NEXTVAL

    Thanks!
    Sorry for the delay. I had waited a little for a reply and then I assumed I would not get any.

    Best regards

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with SELECT NEXTVAL

    After execute query look with QSqlDatabase::lastError() and QSqlQuery::lastError() what happen.

Similar Threads

  1. QSqlQuery problem with SELECT statement
    By virtuosite in forum Newbie
    Replies: 2
    Last Post: 31st August 2009, 08:13
  2. select query with like
    By ag.sitesh in forum Qt Programming
    Replies: 19
    Last Post: 14th April 2008, 05:28
  3. QTableWidget row select
    By nowire75 in forum Newbie
    Replies: 4
    Last Post: 23rd December 2007, 18:59
  4. select a QTreeWidgetItem
    By mattia in forum Newbie
    Replies: 2
    Last Post: 21st December 2007, 11:01
  5. select a particular area
    By vishesh in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 21:44

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.