Connecting Tech Pros Worldwide Forums | Help | Site Map

DBConcurrencyException not firing

niju
Guest
 
Posts: n/a
#1: Mar 29 '06
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();
}


Jason Hales
Guest
 
Posts: n/a
#2: Mar 29 '06

re: DBConcurrencyException not firing


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

Closed Thread