Auto Increment in Datasets

  • Thread starter Thread starter VJ
  • Start date Start date
V

VJ

I have a dataset with a AutoIncrement column.. I write this to a XML file
and read it back..to a Dataset.. The auto increment works perfectly every
time. It picks up were it left...were does it pick up the last value from?..
I mean I thought it uses the max value + 1 logic for existing rows.. not
until I saw this..

I had a dataset with 3 rows..

UnqColumn - 1
UnqColumn - 2
UnqColumn - 3

I removed the last row with ID 3.. and was left with 1 and 2. Now if I
insert a row it should give 3 for the newly inserted row, but it gives me 4.
This also happens even if I write to xml file after the delete and then
reload xml back to a new dataset to insert the row. I can't see to find were
the last value is stored in the XML file.. and how it keeps track of it..
Hey this is really good, works well. But I am curious to learn how this is
done? Can somebody explain?

BTW.. datasets are cool... I am totally in love with it.. endless
possibilities.. no more painful TEMP tables...

VJ
 
Hi VJ,

I removed the last row with ID 3.. and was left with 1 and 2. Now if I
insert a row it should give 3 for the newly inserted row, but it gives me 4.
This also happens even if I write to xml file after the delete and then
reload xml back to a new dataset to insert the row. I can't see to find were
the last value is stored in the XML file.. and how it keeps track of it..
Hey this is really good, works well. But I am curious to learn how this is
done? Can somebody explain?

Sure. You are probably looking at the same table -not the new one loaded
from XML.
Try createing a new dataset, add a new table definition to it, load it from
xml and add a row - you'll see.
It is impossible to restore the last id without info :)
BTW.. datasets are cool... I am totally in love with it.. endless
possibilities.. no more painful TEMP tables...

Yup. They are cool but they have a few bugs here and there.
 
Back
Top