Concurrency Violation

B

Billy Jacobs

I have a client using IE with a .net web application who
is getting a Concurrency Violation whenever she tries to
update certain records in her database.

The strange thing is that I can open up multiple instances
of IE an go to the same page and update the same record
from all 3 instances at the same time as she is getting
the error.

The update is being done using a dataadapter and dataset
with optimistic locking.

Any help would be greatly appreciated.

Billy Jacobs
 
M

Mary Chipman

Are you saying that the same code works for you but doesn't work for
her? You might want to put a Profiler trace on the application
(assuming you are using SQL Server) so you can take a look at what's
going on at the server.

-- Mary
MCW Technologies
http://www.mcwtech.com
 
T

Tian Min Huang

Hello Billy,

Thanks for your post.

Generally speaking, the Update method will raise a DBConcurrencyException
exception when the method encounters a row that fails to update. It seems
to me that your Update statement is based on optimistic concurrency, that
is, records are not locked for editing, and other users or processes can
modify records whenever. It will be the ase that an Update statement will
try to update a row that has been deleted or does not contain the original
values that are found in the DataSet, and thus causes the
DBConcurrencyException.

To workaround this issue, you can explicitly set the UpdateCommand for the
DataAdapter and not rely on automatic commend generation as described in
the KB aticle 308507:

HOW TO: Update a SQL Server Database by Using the SqlDataAdapter Object in
Visual C# .NET
http://support.microsoft.com/?KBID=308507

I'd also like to recommend you the MSDN article below:

Optimistic Concurrency
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconoptimisticconcurrency.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top