Concurrency Violation

G

Guest

I am getting a concurrency violation on an update statement, which is using SQL (not stored procedure). The exception occured only when some records were processed. Ie. same code worked fine for another set of records. Below is the exception text. Any Idea what is happening.

Thanks,

Rajesh Abraham Chacko.

************** Exception Text **************
System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 records.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)
at Itep.DbData.DbUtils.UpdateNewStudents(DataRow[] rwsStudents) in c:\itep.net\itepdbdata\dbdata\dbutils.cs:line 170
at Itep.TrackingSyncBis.BisUtils.ImportUsers(DataRow[]
rwStudentsToImport) in c:\itep.net\trackingsyncbis\trackingsyncbis\bisutils.cs:line 241
at Itep.TrackingSync.frmTrackingSync.btnImportToAd_Click(Object sender, EventArgs e) in c:\itep.net\iteptrackingsync0304\trackingsync.cs:line 911
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
D

David Sceppa

Rajesh,

When the DataAdapter submits a pending change in a DataRow,
it uses the RecordsAffected information returned by the query to
determine whether the update succeeded or failed. If the query
executes without throwing an error but the database reports that
the query affected no records, the DataAdapter interprets this as
a failed update attempt due to a concurrency check that failed
and throws the DBConcurrencyException.

The two common scenarios where the exception occurs are:

1.) When another user has modified the contents of the row.
2.) When the contents of the DataRow are out of synch with the
contents of the database row due to server-generated data
(auto-increment, timestamp, default, etc.) that was not retrieved
after a previous update.

If you could provide more information on the scenario,
chances are you'll get a response that will help explain the
behavior.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
G

Guest

Hi David,

Thanks for your response. In my case no other user is accessing the sane data at that time. i.e. the database id only for this application and only one instance of it is running.

Thanks,

Rajesh Abraham
 
D

David Sceppa

Rajesh,

Is the database generating any values for the row -
auto-increment, timestamp, default, etc?

Can you explain the steps to reproduce the behavior? For
example, "I can successfully insert a row, but if I try to modify
that row without re-querying the database for its contents a
subsequent update attempt fails".

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 

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