Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

This constraint cannot be enabled as not all values have corresponding parent values.  Attempting to create data relation

Posted on 2007-11-20
9
7,203 Views
Last Modified: 2012-08-14
I am trying to create a relation between two tables and get this error message.  I am not sure I understand what constraint it is talking about.  Any ideas are greatly appreciated.

Thanks
Kenny


protected void PopulateProviderTable()
    {

       
        SqlDataAdapter sqlDA = CreateProviderAdapter();
        SqlDataAdapter sqlDAphyins = CreateProviderInsAdapter();
        SqlDataAdapter sqlDAphyspecial = CreateProviderSpecialAdapter();
        SqlDataAdapter sqlDAphyspecialproc = CreateProviderSpecialProcAdapter();
       
       
        errormessage.Text = ProviderSearch;
        errormessage2.Text = SearchProviderIns;
        errormessage3.Text = SearchProvSpecialty;

       // Create Relations - Setup Key Fields
        DataColumn doctorId = HDSDataSet.Tables["PROVIDER"].Columns["PHYSICIAN_NPI"];
        DataColumn insurId = HDSDataSet.Tables["PHYSINS"].Columns["PHYSICIAN_NPI"];
        DataColumn specialtiesId = HDSDataSet.Tables["PHYS_SPECIALTIES"].Columns["PHYSICIAN_NPI"];

        // Create Relations - Build Relation
        DataRelation specialtiesRelation = new DataRelation("specialtiesRelation", doctorId, specialtiesId);
        DataRelation insurRelation = new DataRelation("insurRelation", doctorId, insurId);
        HDSDataSet.Relations.Clear();
        HDSDataSet.Relations.Add(insurRelation);
        HDSDataSet.Relations.Add(specialtiesRelation);----------------<<<<<<<<<<<---------------Line with ERROR
0
Comment
Question by:kwh3856
  • 5
  • 4
9 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20325766
it means that in your underlying tables, not all
PROVIDERs have a record in PHYS_SPECIALTIES  (or the other way around)
0
 

Author Comment

by:kwh3856
ID: 20325768
Additional Info
When I look at the specialtiesRelation in the Watch table the ChildKeyRelation shows Null

If I look at the insurRelation in the watch table, the ChildKeyConstraint shows to be insurRelation

NOT SURE WHY

0
 

Author Comment

by:kwh3856
ID: 20325779
The provider table has three records with the physician_npi set to 100, 200, 300 respectively.  The PHYS_SPECIALITIES table has three records with the same data in the physician_NPI.  Maybe I am not selecting them in my select statement.  I will check.

Thanks
Kenny
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:kwh3856
ID: 20325787
When I look in my dataset using the watch command, the PHYS_SPECIALTIES tables show three records which is what I expected.  Any other ideas?

Thanks
Kenny
0
 

Author Comment

by:kwh3856
ID: 20325795
Also, does each of the table HAVE to have a record for the corresponding table?  I did not know that was a requirement for a relation to be setup.

Thanks
Kenny
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20325816
how many PROVIDER records do you have?
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20325827
try this instead

DataRelation specialtiesRelation = new DataRelation("specialtiesRelation", doctorId, specialtiesId, false);
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20325837
http://codesample.info/index.php/archives/this-constraint-cannot-be-enabled-as-not-all-values-have-corresponding-parent-values/

i believe the error is because not all PHYS_SPECIALTIES records have a matching PROVIDER record, either in the selected subset, or the underlying table
0
 

Author Closing Comment

by:kwh3856
ID: 31410306
Thank you very much.  That resolved my problem.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 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