treatment of duplicate records by sqldataadapter

I use sqldataadapter to add several records to a database.  Some, but not all, of those records may already be included in the source table and may contravene the primary key or unique index.  It seems that when I call sqldataadapter.update it will insert all records until it hits the first duplicate and then insert no more valid (non-duplicate) trades after that point.  What I want it to do is insert all records but ignore, or skip over, the duplicates.  What is the best way for me to achieve this.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi nick,

Try by setting the DataAdapter to:  

da.ContinueUpdateOnError = False

I think it should help you with the problem.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fernando SotoRetiredCommented:
Hi nicksbell;

On the DataAdpater set the ContinueUpdateOnError property to true.

From the Microsoft Documentation:
If ContinueUpdateOnError is set to true, no exception is thrown when an error occurs during the update of a row. The update of the row is skipped and the error information is placed in the RowError property of the row in error. The DataAdapter continues to update subsequent rows.

You should check RowError property of the row to check the rows that had an error.


Nick, now that I read Fernando's comment I see my error. Obviously it should be

da.ContinueUpdateOnError = True

Anyway, that's the property you should set.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.