SqlDataAdapter.Update questions

G

Guest

I'd like to know exactly how an UpdateCommand determines that there are
concurency issues, specifically if I have supplied I created my own update
command, instead of using the SqlCommandBuilder.

The issue I am facing is I have setup a column in my DataTable to map to an
output parameter in my (update) stored proc, using
DA.UpdateCommand.UpdatedRowSource = UpdateRowSource.OutputParameters to
achieve this. This works great until there is a concurrency issue. If the
DataAdapater determines there is a concurrency issue it just skips over this
row all together. This is a problem because internal to the stored procedure
I am doing my own concurrency checking and the output param indicates this.
i.e. 0 = no error, 1 = record updated since last read and 2 = record has been
deleted since last read.

Because of the built in concurrency error the output param doesn't map to
the row and I cannot determine the exact error. This built in concurrency
error is not specific enough for us.

A first chance exception of type 'System.Data.DBConcurrencyException'
occurred in System.Data.dll

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


Can I turn of the built in concurrency check? I tried setting
DA.ContinueUpdateOnError = True, but that didn't work, it still fails due map
the parameter to the column.

Thanks
 
G

Guest

Well, it's been a few days, I thought I'd try to revive this one more time as
my manager is putting a little pressure on me to find the best solution. If
no one has any ideas I guess I'll be forced to go in a complete different
direction, which I was really hoping to avoid.

Thanks.
 
J

JJ

I found out why this used to work for us and then appeared to break. One of
our standard practices is to put Set Nocount On in our sProcs and the
programmer who found this break didn't have that. As soon as he added
everything started working again.

So basically, I guess to answer my own question, to turn off the concurrency
exception just put Set Nocount On in your update stored procedure.
 

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