DataAdapter.Update returns 1 when the row has been deleted

G

Greg

I am testing what happens with our updates when I delete a row after it's
been cached on the client in a Datatable.

I retrieve the record. It sits in a DataRow inside a DataTable on the
client.

I then delete the record in sql server. I then update a field on the client
and call DataAdapter.Update passing in the DataTable.

Our update sproc first checks to see if the row to be updated still exists
by doing a SELECT per the primarykey input param passed into the sproc.

SELECT from table where id = @id

IF @@ROWCOUNT = 0
RETURN

The integer returned from the call to update when the row has been deleted
is always 1. Why? I have confirmed the sproc terminates on the RETURN call
and the update does not continue. So why are the number of rows successfully
updated from the DataSet equal to 1?

I checked the SqlRowUpdatedEventArgs.Status in the Updated event and it is
set to 'Continue'. Why? This should be a DBConcurrencyException IMHO.
 
R

Rajesh Patel

RETURN statement does not generate any error. you should use raiserror
statement to return an error to .net application.

Rajesh Patel
 

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