Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
7,355 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
[X]
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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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