treatment of duplicate records by sqldataadapter

Posted on 2008-11-11
Last Modified: 2013-12-17
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.


Question by:nicksbell
    LVL 20

    Accepted Solution

    Hi nick,

    Try by setting the DataAdapter to:  

    da.ContinueUpdateOnError = False

    I think it should help you with the problem.
    LVL 62

    Assisted Solution

    by:Fernando Soto
    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.


    LVL 20

    Expert Comment

    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now