Concurrency via SqlCommand.ExecuteNonQuery

G

Guest

When using a SqlDataAdapter generated Update StoredProc,
the DataAdapter.UpdateCommend (correctly) returns a
DBConcurrency error.

Using the same stored proc, instead of using the
dataAdapter, I create a SqlCommand object and add all of
the required parameters filled with the appropriate
values of the current and original values. I then use
ExecuteNonQuery to do the update. I get no exception of
any kind when there is a concurrency problem.

Is there no way to handle concurrency issues without
using the DataAdapter?
 
B

Bob Grommes

1) Use an appropriate WHERE clause to insure that no records are updated if
there is a conflict, and an output parameter that returns the number of
records affected.

2) If records effected is zero, throw a DBConcurrencyException.

--Bob
 
G

Guest

Thanks Bob
That was helpful.
-----Original Message-----
1) Use an appropriate WHERE clause to insure that no records are updated if
there is a conflict, and an output parameter that returns the number of
records affected.

2) If records effected is zero, throw a DBConcurrencyException.

--Bob




.
 

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