kwh3856
asked on
This constraint cannot be enabled as not all values have corresponding parent values. Attempting to create data relation
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 = CreateProviderSpecialAdapt er();
SqlDataAdapter sqlDAphyspecialproc = CreateProviderSpecialProcA dapter();
errormessage.Text = ProviderSearch;
errormessage2.Text = SearchProviderIns;
errormessage3.Text = SearchProvSpecialty;
// Create Relations - Setup Key Fields
DataColumn doctorId = HDSDataSet.Tables["PROVIDE R"].Column s["PHYSICI AN_NPI"];
DataColumn insurId = HDSDataSet.Tables["PHYSINS "].Columns ["PHYSICIA N_NPI"];
DataColumn specialtiesId = HDSDataSet.Tables["PHYS_SP ECIALTIES" ].Columns[ "PHYSICIAN _NPI"];
// Create Relations - Build Relation
DataRelation specialtiesRelation = new DataRelation("specialtiesR elation", doctorId, specialtiesId);
DataRelation insurRelation = new DataRelation("insurRelatio n", doctorId, insurId);
HDSDataSet.Relations.Clear ();
HDSDataSet.Relations.Add(i nsurRelati on);
HDSDataSet.Relations.Add(s pecialties Relation); ---------- ------<<<< <<<<<<<--- ---------- --Line with ERROR
Thanks
Kenny
protected void PopulateProviderTable()
{
SqlDataAdapter sqlDA = CreateProviderAdapter();
SqlDataAdapter sqlDAphyins = CreateProviderInsAdapter()
SqlDataAdapter sqlDAphyspecial = CreateProviderSpecialAdapt
SqlDataAdapter sqlDAphyspecialproc = CreateProviderSpecialProcA
errormessage.Text = ProviderSearch;
errormessage2.Text = SearchProviderIns;
errormessage3.Text = SearchProvSpecialty;
// Create Relations - Setup Key Fields
DataColumn doctorId = HDSDataSet.Tables["PROVIDE
DataColumn insurId = HDSDataSet.Tables["PHYSINS
DataColumn specialtiesId = HDSDataSet.Tables["PHYS_SP
// Create Relations - Build Relation
DataRelation specialtiesRelation = new DataRelation("specialtiesR
DataRelation insurRelation = new DataRelation("insurRelatio
HDSDataSet.Relations.Clear
HDSDataSet.Relations.Add(i
HDSDataSet.Relations.Add(s
ASKER
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
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
ASKER
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
Thanks
Kenny
ASKER
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
Thanks
Kenny
ASKER
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
Thanks
Kenny
how many PROVIDER records do you have?
try this instead
DataRelation specialtiesRelation = new DataRelation("specialtiesR elation", doctorId, specialtiesId, false);
DataRelation specialtiesRelation = new DataRelation("specialtiesR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. That resolved my problem.
PROVIDERs have a record in PHYS_SPECIALTIES (or the other way around)