Set the DataSet Relations
hi all,
I have a dataset with 5 tables:
tb_Projects(pk_ProjectID,name,...)
tb_Donors(pk_DonnorID,name,...)
tb_Clients(pk_ClientID,code,name,...)
tb_ProjectDonors(pk_ProjectDonorID,fk_projectID,fk_DonnorID)
tb_ProjectClients(pk_ProjectClientID,fk_ClientID,fk_ProjectID).
And the code, i set the Relation as below:
ds.Relations.Add( "ProjectProjectDonors", ds.Tables["Projects"].Columns["pk_ProjectID"],
ds.Tables["ProjectDonors"].Columns["fk_ProjectID"]);
ds.Relations.Add( "ProjectDonors", ds.Tables["ProjectDonors"].Columns["fk_DonnorID"],
ds.Tables["Donors"].Columns["pk_DonnorID"]);
ds.Relations.Add( "ProjectProjectClients", ds.Tables["Projects"].Columns["pk_ProjectID"],
ds.Tables["ProjectClients"].Columns["fk_ProjectID"]);
ds.Relations.Add( "ProjectClients", ds.Tables["ProjectClients"].Columns["fk_ClientID"],
ds.Tables["Clients"].Columns["pk_ClientID"]);
But in the runtime the system shows error "This constraint cannot be enabled as not all values have corresponding parent values" at the row :
ds.Relations.Add( "ProjectClients", ds.Tables["ProjectClients"].Columns["fk_ClientID"],
ds.Tables["Clients"].Columns["pk_ClientID"]);
Please help me to fix this.
Thanks,
Tin Nguyen