Hi Ant,
I think that you are not doing it right.
So, you check whether the data wasn't changed on database and then you do an
update if data wasn't changed, correct?
If so, then it is wrong and a performance hit. What if somebody changes data
between your check and your update?
See, you can't know that data wasn't changed before doing an update (unless
you heavily lock your database) and you don't need to.
Just try to do an update wrapped in a transaction and using concurrency
checking. If the update succeeds then it is ok, if it doesn't succeed then
you will know that data was changed and decide what do to.
HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
Ant said:
Hi, Cor,
Thanks for the advice. I think that's probably the best way. I didn't
realize that optimistic concurrency was a default. Now I see that it
throws
an error on finding the underlying data changed, I can work with that.
Thanks
again.
Hello Miha,
Why would I want to know? well, I have a server with a few clients each
holding a Dataset derived from the data on the server. Datasets are
disconnected. If one user updates a row back to the server on one client,
then another user updates the same row from a dataset on another client,
the
two different updates may cause data integrity problems. Which update
would
be correct? (what if only col 1 was updated in update 1 but only col 2 was
updated in update two; I would lose the col 1 update).
So I need to control this.
Hope this helps
Thanks for your help
Ant
Miha Markic said:
Hi Ant,
Why would you need to know?
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
Hi,
Is there a way to check if a records in the underlying database have
been
updated by another client?
ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has
changed
the underlying data that you are just about to send changes to from
your
own
DataSet to?
Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified
original
rows?
Is this how its done?
thanks for any ideas in advance
Ant