DBConcurrency Exception

G

Guest

Hi ,

I would like to know when does DBConcurrencyException exactly occur. What i
want is to catch data concurrecy conflicts in a multi user environment.

I know how to do it in classic ADO by using UpdateBatch method which throws a
Hresult = DB_E_CONCURRENCYVIOLATION.After this you can set a filter on the
recordset and call ADO resync method.

How can the same be achieved in ADO.Net ??

Situation: User A reads in a table makes changes. User B read after that.
User B modifies data and writes it back to database. Now A had stale data
with him. When he go to update the database table will a DBConcurrency
exception get raised.

I have tried this with a sample where i have two independant
OleDBDataadapters and two datasets to simulate two users basically. Every
time i try to update a record
which has got changed in underlying db by some other user it suceeds , in
stead of failing as concurrency conflict has occured.

Is there any other way to simulated this kind of a situation.

Regards
Vikram Lagu
 
M

Mark Ashton

The DBConncurrencyException is thrown when DbDataAdapter.Update method
executes the UpdateCommand or DeleteCommand and IDataRecord.RecordsAffected
property reports 0 record affected.

Against SQL Server, if you have 'SET NOCOUNT ON', the -1 is always returned
for records affected and the client will not know if any records were
affected on the server for updates and deletes.
 

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