Solved

How to merge only the missing rows

Posted on 2011-09-13
1
352 Views
Last Modified: 2012-06-22
I have this code.

However I got an exception in the merge line:

Failed to enable constraints. One or more rows contain values violating non-null
I would like a simple way, that it merges the missing rows only, if there are rows that already exist, it shouldn't try to copy them

Thanks


public UC010_WizardStepBusinessParkDataSet GetBusinessParkData(Int32 businessParkID)
        {
            // Init
            UC010_WizardStepBusinessParkDataSet dataSet = new UC010_WizardStepBusinessParkDataSet();
            View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkData vwBusPark = new View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkData();
            View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkPortfolioManagerData vwBusParkPortfolioMngr = new View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkPortfolioManagerData();

            vwBusPark.Where.BusinessParkID.Value = businessParkID;
            vwBusParkPortfolioMngr.Where.BusinessParkID.Value = businessParkID;

             if (vwBusPark.Query.Load())
                dataSet.BusinessPark.Merge(vwBusPark.toDataTable(), true, System.Data.MissingSchemaAction.Ignore);

Open in new window

0
Comment
Question by:Simbios
1 Comment
 
LVL 7

Accepted Solution

by:
Norush earned 500 total points
ID: 36535246
Try merging with:

vwBusPark.Except(dataSet.BusinessPark, DataRowComparer<YourRow>.Default)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

13 Experts available now in Live!

Get 1:1 Help Now