in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Primary key auto-incrementing incorrectly

Last post 05-14-2007 2:13 AM by g18c. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-13-2007 5:34 AM

    • g18c
    • Top 500 Contributor
    • Joined on 05-13-2007
    • Posts 4

    Primary key auto-incrementing incorrectly

    Hi, i have made a data source connection to a very simple database, UserID, Firstname and Lastname. I dragged the dataset onto the form and all looks well, i can add users and save records correctly.

    But if i enter a new row, enter some details, then click to enter a new row the autonumber is incremented correctly, for example to 6. I then click off (and cancel the insert), i click back into the row to enter a new record and the number is now 7, even though the last row was not commited.

    Is this by design, my bad code, or a bug? Any ideas?

    Cheers,

    Chris

  • 05-14-2007 1:36 AM In reply to

    • PUT
    • Top 150 Contributor
    • Joined on 02-17-2007
    • Posts 8

    Re: Primary key auto-incrementing incorrectly

    I might not understand your question, but have a look at the "rowid"-column that always exists (you don't have to add it yourself) which is "autoincremental".
  • 05-14-2007 1:41 AM In reply to

    Re: Primary key auto-incrementing incorrectly

    Autoincrement behavior is documented here: http://www.sqlite.org/autoinc.html


    Regards

    Jesús López

  • 05-14-2007 2:13 AM In reply to

    • g18c
    • Top 500 Contributor
    • Joined on 05-13-2007
    • Posts 4

    Re: Primary key auto-incrementing incorrectly

    Sorry what i mean is this:

    I have a number of rows entered, IDs 0-5 used, with name details for each row, thats ok. I then click to add a new row in the bottom of the datagrid, the ID is incremented to 6. I dont enter any data but instead click elsewhere thus canceling the comit. I then click back into the bottom of the datagrid and instead of 6 being used the ID is now 7, (i think it should be 6 as that record was never actually comitted).

    Furthermore, if the form is closed and re-opened, when i click to enter a new row it will go back to using the ID 6 which is correct. sorry for the confusing explanation.

    Chris

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems