Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:21:34+00:00 2026-05-14T02:21:34+00:00

If I fill the DataSet with DataAdapters that select all rows from Orders and

  • 0

If I fill the DataSet with DataAdapters that select all rows from Orders and Customers and call:

private void CreateRelation() 
{
    // Get the DataColumn objects from two DataTable objects 
    // in a DataSet. Code to get the DataSet not shown here.
    DataColumn parentColumn = 
        DataSet1.Tables["Customers"].Columns["CustID"];
    DataColumn childColumn = 
        DataSet1.Tables["Orders"].Columns["CustID"];
    // Create DataRelation.
    DataRelation relCustOrder;
    relCustOrder = new DataRelation("CustomersOrders", 
        parentColumn, childColumn);
    // Add the relation to the DataSet.
    DataSet1.Relations.Add(relCustOrder);
}

(from http://msdn.microsoft.com/en-us/library/system.data.datarelation.aspx)

there will be a runtime error if there is orders that do not have customers. This might happen when a buggy program has not deleted customer’s orders when customer was deleted.

What can I do except put Orders select string a additional where-condition:

CUSTID IN (SELECT DISTINCT CUSTID FROM CUSTOMERS)

OR: is it really that way (that all children have to have parents)? My code might have a bug also. The exception occurs when IN MY CODE I add the relation to filled DataSet. The exception is:

An unhandled exception of type ‘System.ArgumentException’ occurred in System.Data.dll

Additional information: This constraint cannot be enabled as not all values have corresponding parent values.

Thanks & Best Regards – Matti

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:21:34+00:00Added an answer on May 14, 2026 at 2:21 am

    there’s an overload on the Add() method that includes a bool value to enforce constraints or not. I think I’ve used it in the past like this:

    DataRelation dr = ds.Relations.Add("name", DataColumnParent, DataColumnChild, false);
    

    EDIT

    Sorry, the only overload is on this method signature: http://msdn.microsoft.com/en-us/library/3zy636kc.aspx

    DataRelationCollection.Add(String, DataColumn[], DataColumn[], bool)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fill a form in a php application from a C#
When using wireframe fill mode in Direct3D, all rectangular faces display a diagonal running
What would be the best way to fill a C# struct from a byte[]
What would be the best way to fill an array from user input? Would
I fill a collection one single time when my J2EE webapp starts. Then, several
I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers:
I want to fill a map with class name and method, a unique identifier
Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been
Is there a better way I can fill out a spread sheet on a
I used a new Date() object to fill a field in a MySQL DB,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.