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'm learning Databinding from here http://www.akadia.com/services/dotnet_databinding.html I'm just updating the dataset and then updating
I have seen many references stating that TableAdapters are weak and silly, and that
before a little time , I used a code to get the dates between
I'm trying to learn ADO.NET from Programmers Heaven: C# School Thats the code I've
I built a dialog so that when the user decides to print the DataGridView,
Below is the code that I'm using in ms access to list the data
As my experience with .Net really began as working on existing in-house applications for
I am not as familiar with Oracle as I would like to be. I
I got no errors in the code now, but it doesn't seem to work.

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.