G
Guest
Hi,
I have an ACCESS database, with 2 tables. The realtionship between tables is
set 1:1.
I put those tables into dataset and set up the foreign key constraints:
DataColumn parent = ds.Tables["Empl].Columns["AdvertisementID"];
DataColumn child = ds.Tables["Pictures"].Columns["AdvertisementID"];
ForeignKeyConstraint fk = new ForeignKeyConstraint("FK_Empl_Pictures",
parent, child);
fk.UpdateRule = Rule.Cascade;
fk.DeleteRule = Rule.SetNull;
ds.Tables["Pictures"].Constraints.Add(fk);
When Pictures database is empty, everything is OK. If I add records to
Picture db (=using Access directly), I get error message while running
mentioned code.
"This constraint cannot be enabled as not all values have corresponding
parent values.
"
Thats is not true, as Access would not allowe to corrupt the relationsip by
adding values.
Any idea what is wrong here?
Thanks,
Lubomir
I have an ACCESS database, with 2 tables. The realtionship between tables is
set 1:1.
I put those tables into dataset and set up the foreign key constraints:
DataColumn parent = ds.Tables["Empl].Columns["AdvertisementID"];
DataColumn child = ds.Tables["Pictures"].Columns["AdvertisementID"];
ForeignKeyConstraint fk = new ForeignKeyConstraint("FK_Empl_Pictures",
parent, child);
fk.UpdateRule = Rule.Cascade;
fk.DeleteRule = Rule.SetNull;
ds.Tables["Pictures"].Constraints.Add(fk);
When Pictures database is empty, everything is OK. If I add records to
Picture db (=using Access directly), I get error message while running
mentioned code.
"This constraint cannot be enabled as not all values have corresponding
parent values.
"
Thats is not true, as Access would not allowe to corrupt the relationsip by
adding values.
Any idea what is wrong here?
Thanks,
Lubomir