DBConcurrencyException not firing

Discussion in 'ASP .Net' started by niju, Mar 29, 2006.

  1. niju

    niju Guest

    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();
    }
     
    niju, Mar 29, 2006
    #1
    1. Advertisements

  2. niju

    Jason Hales Guest

    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
     
    Jason Hales, Mar 29, 2006
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.