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();
}
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();
}