我有一個包含少量表的DataSet,其中2個與Conatraint中的XSD文件中的相關。c#DataSet無法進行此更改,因爲在關係XXX上實施了約束,並且更改此值將會顛覆子行
當我保存(與數據適配器更新)父表我得到這個錯誤:
Cannot make this change because constraints are enforced on relation XXX, and changing this value will strand child rows.
XXX是在XSD文件的關係。
我簡直不明白這是什麼,我試過谷歌,但沒有。
父表ID與FK連接到子表中的列,並且保存父表應更新子表。
我不明白這個錯誤,請幫忙。
編輯:
,在子表MyDataSet.Patient_IVFOocytesFreezeOocytesInGroups創建新行的代碼:
// connect the oocytes with a group
IVFOocyteManagerDataset.Patient_IVFOocytesFreezeOocytesInGroupsRow newgrouprow = MyDataSet.Patient_IVFOocytesFreezeOocytesInGroups.NewPatient_IVFOocytesFreezeOocytesInGroupsRow();
if (selectedStraws.Count == 1)
{
int g = MyDataSet.Patient_IVFOocytesFreezeStraw.Where(x => x.IsSelecetd == true).Select(x => x.group_id).FirstOrDefault();
newgrouprow.group_id = MyDataSet.Patient_IVFOocytesFreezeGroups.Where(x => x.group_id == g).Select(x => x.group_id).SingleOrDefault();
OocyteStraws.Rows[i].StrawDisplayId = MyDataSet.Patient_IVFOocytesFreezeStraw.Where(x => x.IsSelecetd == true).Select(x => x.display_id).FirstOrDefault();
}
else
{
OocyteStraws.Rows[i].StrawDisplayId = -1;
newgrouprow.group_id = selectedStraws.Select(x => x.group_id).FirstOrDefault();
}
MyDataSet.Patient_IVFOocytesFreezeGroups是父表。
看起來您已將xml文件導入到數據表中,並且結果與模式(xsd)不匹配。您插入到數據表中的值與模式不匹配。 – jdweng