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,103 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now