Results 1 to 5 of 5

Thread: How to find the ROWID after an insert into an SQLite table?

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default How to find the ROWID after an insert into an SQLite table?

    OK, I know I should probably be using a QSQLTableModel or something like that, but I have a quick demo to do, not much time to learn these models until later.
    I'm trying to insert data with query.exec("insert....")and would like to know what ROWID was in fact inserted.
    Any suggestions?


    But maybe you can convince me that QSQLTableModel is so easy to learn I can get it running in an hour...

  2. #2
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to find the ROWID after an insert into an SQLite table?

    You can use the SQLite function last_insert_rowid()

  3. #3
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to find the ROWID after an insert into an SQLite table?

    thank you, but at first view using a SQLite function seems to leave the Qt Framework. What header files will I be using? Do I need to download anything?

  4. #4
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to find the ROWID after an insert into an SQLite table?

    OK I can use "SELECT last_insert_rowid();" as an SQL Query
    I put this up to help the readers.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to find the ROWID after an insert into an SQLite table?


Similar Threads

  1. SQLITE insert problem
    By rdf in forum Qt Programming
    Replies: 3
    Last Post: 23rd September 2011, 07:13
  2. QSqlTableModel Unable to find table with SQlite
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2011, 14:33
  3. Replies: 2
    Last Post: 4th August 2010, 13:06
  4. How to insert row to SQLite database?
    By MIH1406 in forum Qt Programming
    Replies: 6
    Last Post: 29th May 2010, 12:22
  5. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56

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