DBConcurrencyException not firing

N

niju

Hi all,
I am using following code to update database; I am running two
instances of the application and updating the same record. However,
DBConcurrencyException doesn't fire. Is there something I am missing
in the code?

DataRow[] _err = null;
DataSet dsGetChanges = _nodeDataSet.GetChanges(DataRowState.Modified);

if (dsGetChanges != null)
{
SqlDataAdapter sqlDA = null;
try
{
sqlDA = _nodeDataAdapter;
sqlDA.ContinueUpdateOnError = true;
sqlDA.SelectCommand.Connection.Open();
sqlDA.Update(dsGetChanges);
if (dsGetChanges.HasErrors)
{
_err= dsGetChanges.Tables[0].GetErrors();
}
_nodeDataSet.Merge(dsGetChanges);
_nodeDataSet.AcceptChanges();
}
catch (DBConcurrencyException ex)
{
MessageBox.Show(ex.Message);
_nodeDataSet.RejectChanges();
}
finally {
_nodeDataAdapter.SelectCommand.Connection.Close();
_nodeDataAdapter.SelectCommand.Dispose();
}
 
J

Jason Hales

It might because of your line: sqlDA.ContinueUpdateOnError = true

As the name suggests it will continue prcoessing updates even if an
error is encountered during a row update. I guess this also includes
DBConcurrencyException
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top