views:

217

answers:

2

I have a code like this.

DBContext is Datacontext instance.

try
            {
                TBLORGANISM org = new TBLORGANISM();
                org.OrganismDesc = p.Subject;
                DBContext.TBLORGANISMs.InsertOnSubmit(org);
                DBContext.SubmitChanges();
            }
            catch (Exception)
            {
            }

At this point, I want to IGNORE the error and want to be skipped. Not to be retried. But when I try another insert like

                TBLACTION act = new TBLACTION();
                act.ActionDesc = p.ActionName;
                DBContext.TBLACTIONs.InsertOnSubmit(act);
                DBContext.SubmitChanges();

SubmitChanges firstly retries previous attempt.

How can I tell "skip errors, don't try again"?

+1  A: 

Create a new instance of DBContext the second time.

But why do you want to skip errors?

Raj Kaimal
+1  A: 

Try this: DBContext.SubmitChanges(ConflictMode.ContinueOnConflict). Hope it will help.

Alexander