1. there is NO automatic concurrancy checking. the closest visual studio
comes to it is if you use the data adapter wizard to "generate sql
statements" and, under the advanced tab, you select "use optimistic
concurrancy". What this does is simply generate a UPDATE SQL statement that
compares the prior value of all the fields to the current value in the WHERE
clause. If any field has changed the update does not occur (ie: zero records
are updated). This corresponds to the "whole record" method of concurrancy
checking. The other method is to compare last updated timestamp, or some
sort of version number for the record. (ie each time you update a record you
either update the timestamp, or increment the version by 1). The important
thing to realize is that this is basically all a manual method of doing
concurrancy checking. If you don't use the wizard (I never do) then you have
to code some sort of concurrancy check into your update statement manually.
2. there is an exception called "DBConcurrencyException" which, by it's
name, seems to indicate that it will catch concurrency violations... WRONG.
Reading the documentation for it, this exception will be thrown "whenever 0
records are affected" by an sql statement (ie an update statement). Reading
the documentation reveals that "when 0 records are affected it is PROBABLY
due to a concurrency violation" (which YOU have coded in your WHERE clause).
So, the bottom line is this... if you want to catch a concurrency violation
you have to code it yourself using your own methodology. The only tool
ADO.NET gives you is to throw a DBConcurrencyException when 0 records are
affected by an SQL statement. Everything else is up to you to code. Now, I'm
not saying that this is necessarily bad, I'm just saying that it would have
been nice is MS didn't dance around the issue and make it PERFECTLY CLEAR
that there is no automatic concurrency check.
I believe the above statements are correct to the best of my knowledge. I
provide no warrantee, guarantee, or represent that I have any brains at all.
Regards,
John
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O7****************@TK2MSFTNGP12.phx.gbl...
User A and User B modify the same record, UserB save first.
As User A save it , I will get the concurrency error.
I know I can use
Try
.... dsTable.udpate()
catch err As DbCurrency
messagebox.show("UpdateFailed ")
end try
However, How can I let User A know "User B save the same record already ",
and ask USER A whether overwrite it or not , If User A press "Yes" , his
record should saved correctly.
Does anyone know how to do ??
Thanks a lot.