Click here to Skip to main content
12,635,269 members (22,940 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

29.9K views
3 bookmarked
Posted

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

, 5 Dec 2009 CPOL
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)

Share

About the Author

shayke23
Israel Israel
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralAre you sure that this work? I'm using .NET4 and SQLite and ... Pin
real-insanity14-Dec-11 3:29
memberreal-insanity14-Dec-11 3:29 
GeneralMeaning in that order.You Clear(),Fill() and Update() Pin
Member 81391345-Aug-11 5:46
memberMember 81391345-Aug-11 5:46 
GeneralConcurrency violation case. Pin
Navneet Hegde7-Dec-09 2:59
memberNavneet Hegde7-Dec-09 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 5 Dec 2009
Article Copyright 2009 by shayke23
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid