G
Guest
Using an informix database, I'm retrieving two datasets and copying the data
table from one dataset into the other, so I've got 1 dataset with 2 tables.
This is just background because it might be part of the problem.
After this, I simply want to create a data relation between the two tables,
so I call the constructor for a new datarelation, which appears to work fine.
I get an error when I'm trying to use the Add method of the dataset. The
error is:
"System.ArgumentException: This constraint cannot be enabled as not all
values have corresponding parent values."
Any ideas? Below is the code I'm using.
Thanks!
Diane Droubay
-----------------------------
//copy the budget detail from the detail dataset, then add to the budget
dataset
DataTable dt = dsDetail.Tables[0].Copy();
dsBudget.Tables.Add(dt);
dsBudget.Tables[0].TableName = "Budget";
dsBudget.Tables[1].TableName = "Detail";
DataColumn dcBudgetId;
DataColumn dcBudgetDetailId;
//budget_id is primary key in Budget table and foreign key in Detail table.
dcBudgetId = dsBudget.Tables["Budget"].Columns["budget_id"];
dcBudgetDetailId = dsBudget.Tables["Detail"].Columns["budget_id"];
DataRelation rel = new DataRelation("Budget2Detail", dcBudgetId,
dcBudgetDetailId);
//crashes on the next call.
dsBudget.Relations.Add(rel);
table from one dataset into the other, so I've got 1 dataset with 2 tables.
This is just background because it might be part of the problem.
After this, I simply want to create a data relation between the two tables,
so I call the constructor for a new datarelation, which appears to work fine.
I get an error when I'm trying to use the Add method of the dataset. The
error is:
"System.ArgumentException: This constraint cannot be enabled as not all
values have corresponding parent values."
Any ideas? Below is the code I'm using.
Thanks!
Diane Droubay
-----------------------------
//copy the budget detail from the detail dataset, then add to the budget
dataset
DataTable dt = dsDetail.Tables[0].Copy();
dsBudget.Tables.Add(dt);
dsBudget.Tables[0].TableName = "Budget";
dsBudget.Tables[1].TableName = "Detail";
DataColumn dcBudgetId;
DataColumn dcBudgetDetailId;
//budget_id is primary key in Budget table and foreign key in Detail table.
dcBudgetId = dsBudget.Tables["Budget"].Columns["budget_id"];
dcBudgetDetailId = dsBudget.Tables["Detail"].Columns["budget_id"];
DataRelation rel = new DataRelation("Budget2Detail", dcBudgetId,
dcBudgetDetailId);
//crashes on the next call.
dsBudget.Relations.Add(rel);