concurrency in ado.net

  • Thread starter Thread starter Archana
  • Start date Start date
A

Archana

Hi all,

I want to handle concurrency issue when 2 user try to update same
record.

What i want is if user1 and user2 are accessing same record and user2
has updated same record then when user1 tries to update that record he
should able to update it. Which is not happening currently.

Can anyone tell me what should i do?

thanks in advance.
 
I won't question whether what you are doing is good or bad.
But if you want to overwrite data you might remove WHERE part of
UPDATE/DELETE adapter's commands.
 
Archana,

That depends if it is something as this
Name = Cor
Name = Miha

Than it is not so important, the name is just set and which one was first is
just a matter of seconds who came first.

However if if is the result of this.
Bankaccount = 100000 (where 100000 is the result of 1000 + 99000)
Bankaccount = 1000 (where 100 is the result of 100000 - 99000)

Than I shall *not* use the method Miha shows. (As he told in a way in his
message he don't want to discuss, but he will find it of course as well
bad).

Cor
 
Ah, no. You can't remove the WHERE clause as this uniquely identifies the
row to update. If you do remove the WHERE clause, all rows in the table will
be updated. You can remove the portion of the WHERE clause that checks for
changes by other users.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Miha Markic said:
I won't question whether what you are doing is good or bad.
But if you want to overwrite data you might remove WHERE part of
UPDATE/DELETE adapter's commands.

--
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/

Archana said:
Hi all,

I want to handle concurrency issue when 2 user try to update same
record.

What i want is if user1 and user2 are accessing same record and user2
has updated same record then when user1 tries to update that record he
should able to update it. Which is not happening currently.

Can anyone tell me what should i do?

thanks in advance.
 
William (Bill) Vaughn said:
Ah, no. You can't remove the WHERE clause as this uniquely identifies the
row to update. If you do remove the WHERE clause, all rows in the table
will be updated. You can remove the portion of the WHERE clause that
checks for changes by other users.

:-)
Of course. At least unique identifier has to be present. My bad.
 
Back
Top