How does dataset stores old value?
Suppose we have changed several records and when do we save the recrds it sends the update command to database with new changed and old values.
Printable View
How does dataset stores old value?
Suppose we have changed several records and when do we save the recrds it sends the update command to database with new changed and old values.
If I remember correctly it works like this:
When you make changes to a row in a datatable the row's rowstate property i changed to "modified" and if you delete the row it actually is not removed but just marked as "deleted" in the rowstate property. When the dataset is updated against the database it updates the database with the modifications on all rows that are not marked as "unchanged" in the rowstate property.
This should mean that it does not store the old data, it changes the data and marks the row as "modified" and when updating to db does the update with a big, kinda complex UPDATE query.
Anyone feel free to correct me if I'm remembering incorrectly.
/Nisse
Thanks for the answer.
But I found that the updatequery is something like
update table set fld1=?,.......
where fld1=?,.......
to execute this query we should pass the new changed value before "where" field1=newvalye,... and should pass the old value
after "where" where field1=oldvalue and ...........
You are correct, I had a memory flaw I guess. =)
If you use .NET to build a update command it will use 2 sets of parameters, one set with "new values" and one set with "original values". Those parameters differs in the SourceVersion property, current or original.
I almost always work with typed datasets so all this is done in the background.
/Nisse