Concurrency violation override for delete.

C

Chris Hock

I'm using VS.Net 2003 (C#). I have a data adapter which
performs simple CRUD operations on a table. When creating
the data adapter I opted NOT to use the Optimistic
concurrency.

The sql update statement works as expected. The row
updates regardless of whether the data was modified after
the read and prior to the update. However, the delete
appears to always require a row be deleted. My
application reads the row, then I delete the row from the
SQL Server table manually, and then I try to delete the
row with the application.

If I turn off Optimistic concurrency I would expect the
delete statement to not care whether the row existed or
not. However, it appears that it requires at least one
row to be deleted regardless of whether Optimistic
concurrency is used or not.

Does anyone know a way around this issue? I want the
delete operation to succeed regardless of how many rows
are deleted.

Thanks,
Chris
 
W

William \(Bill\) Vaughn

How was the DeleteCommand constructed? You can build it any way you wish--as
long as it returns rows affected = 1.


--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
D

David Sceppa

Chris,

Concurrency checks are built into the query the DataAdapter
executes to submit the pending change. There is no property for
the DataAdapter to check to achieve this behavior. Your best bet
would be to use just the key column(s) in WHERE clause for the
DeleteCommand's query, and then add code to the RowUpdated event
to check for delete attempts that affected no records and
interpret that result as success.

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