Concurrency violation: the DeleteCommand affected 0,一个解决dataset并发删除冲突的方法

Set ContinueUpdateOnError = true, then do some action with the errors.

 

    dtaMailingList.ContinueUpdateOnError = true;

    int iAffectedRows = dtaMailingList.Update(dsMailingListInfo,"MailingList");


    if (dsMailingListInfo.MailingList.HasErrors)
    {
     DataRow[] drs = dsMailingListInfo.MailingList.GetErrors();
     foreach (DataRow dr in drs)
      if (dr.RowError.IndexOf("Concurrency violation") > -1)
       dsMailingListInfo.MailingList.RemoveMailingListRow((MailingListInfo.MailingListRow)dr);
     dsMailingListInfo.MailingList.AcceptChanges();

     // If the dataset still has errors, then an exception needs to be thrown

     if (dsMailingListInfo.MailingList.HasErrors)
      throw new DataException("An exception was raised while updating the mail list: " +
       dsMailingListInfo.MailingList.GetErrors()[0].RowError);
    }*

posted @ 2009-02-02 17:16  helloworld22  阅读(712)  评论(0)    收藏  举报