Click here to Skip to main content
Click here to Skip to main content

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

, 4 Dec 2009
Rate this:
Please Sign up or sign in to vote.
hi all.i've just encountered a problem in C#:"Concurrency violation: the UpdateCommand affected 0 of the expected 1 records".that is an exception raised when there is a mismatch between the time that the DataTable reads from the DB until the time it wants to update it.one can use 2...
hi all.
i've just encountered a problem in C#:
"Concurrency violation: the UpdateCommand affected 0 of the expected 1 records".
 
that is an exception raised when there is a mismatch between the time that the DataTable reads from the DB until the time it wants to update it.
 
one can use 2 functions: dataAdapter.Fill(dataTable) and dataAdapter.Update(dataTable)
 
my problem was that i 1st made Fill(), then made changes to the table, than 2nd made Update(). until now it worked perfect. now when i want to make further Update() calls i get this Exception.
 
after some hours...i've figured out that all u need to do is use dataTable.Clear() and than call the Fill() method again and it works perfect!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

shayke23

Israel Israel
No Biography provided

Comments and Discussions

 
GeneralAre you sure that this work? I'm using .NET4 and SQLite and ... Pinmemberreal-insanity14-Dec-11 2:29 
GeneralMeaning in that order.You Clear(),Fill() and Update() PinmemberMember 81391345-Aug-11 4:46 
GeneralConcurrency violation case. PinmemberNavneet Hegde7-Dec-09 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 5 Dec 2009
Article Copyright 2009 by shayke23
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid