Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Reply
 
Old 12-12-2008   #1 (permalink)
Goldenrate


 
 

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

Hi,

I have the following method in an object name SpouseBLL:

[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Update,true)]
public bool UpdateSpouse(Spouse obj) {
//Create a new product row instance
MRF.MRF_SpouseDataTable spouses =
Adapter.GetSpouseByGuestId(obj.GuestId);
MRF.MRF_SpouseRow spouse = spouses[0];

spouse.FirstName = obj.FirstName;
spouse.LastName = obj.LastName;
spouse.GuestId = obj.GuestId;
spouse.MobilePhone = obj.MobilePhone;
spouse.Email = obj.Email;
spouse.LectureLanguage = obj.LectureLanguage;
spouse.DateOfBirth = obj.Dob;

//Add the new spouse
int rowsAffected = Adapter.Update(spouse);
return rowsAffected == 1;
}
When I try to update the database I receive the following error:
Quote:
Quote:
Quote:

>>>>>>>>>>>Concurrency violation: the UpdateCommand affected 0 of the
>>>>>>>>>>>expected 1 records.
I have written the exact method for another object and it works with no
problem.

Thanks,
David


My System SpecsSystem Spec
Old 12-12-2008   #2 (permalink)
\Ji Zhou [MSFT]\


 
 

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

Hello David,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you are getting a
DBConcurrencyException when trying to use a DataAdapter to update the data
source. If there is any misunderstanding, please feel free to let me know.

This is a typical concurrency issue. The DBConcurrencyException is thrown
by a DataAdapter during the update operation if the number of rows affected
equals zero.
(http://msdn.microsoft.com/en-us/libr...rencyexception.
aspx)

For this kind of issue, there are two possibilities.

1. Another user is trying to update data in database. For the data is
modified, our DataAdapter cannot find the original data and throws the
exception. So, we have to write our logical codes to handle this situation
following the try/catch structure found in,
http://msdn.microsoft.com/en-us/libr...xy(VS.80).aspx

2. There is a problem related to UpdateCommand. If this is case, I would
like suggest you use the tool SQL profiler in the server side to observe
every incoming request. Then we can know what update command cause this
exception. See the http://msdn.microsoft.com/en-us/library/ms187929.aspx.

Have a good weekend!


Best regards,
Ji Zhou (v-jzho@xxxxxx, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxx.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

My System SpecsSystem Spec
Old 12-21-2008   #3 (permalink)
\Ji Zhou [MSFT]\


 
 

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

Hello David,

I am writing to check the status of the issue on your side. Are my
suggestions helpful for your scenario? If you need any future assistance,
please feel free to let me know. I will be more than happy to be of help.

Have a great day!

Best regards,
Ji Zhou (v-jzho@xxxxxx, remove 'online.')
Microsoft Online Community Support


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Vista - firewall affected DSL speed Vista performance & maintenance
Custom Http Handler Factory and Possible Concurrency Issues on Application Start .NET General
list of programs that are affected by SP1 Vista General
SP1 RC1 affected my hibernate Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46