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,183 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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