Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Posts
    11

    Unanswered: SQLite - get next AUTOINCREMENT value

    Hi,

    I have a PK which is an AUTOINCREMENT attribute.

    Does anyone know how (if possible) to get the next value that would be automatically allocated to the PK with the next insertion?

    Cheers

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    don't try to get it before the insertion, get it afterwards with last_insert_rowid
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2008
    Posts
    11
    I feared as much. I need the value before the insert command.

    I'm dealing with a .NET DataSet. When I insert a row, the insertion goes fine at the database when I call dataSetName.Update(). But the "in memory" PK of the DataSet remains a NULL value, and it does not know what value the database has allocated to the new PK.

    Bummer. Cannot figure out a way around this one.

Posting Permissions

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