Newbie help with relations

G

Guest

Hi,

I have two tables in a dataset. I want to create a relation between the two
tables in which the child table can have foreign keys that do not match
primary key fields in the parent table. When the parent table is updated, I
want any related foreign key fields in the child table to be updated, but I
don't want any deletions to be cascaded. I've tried setting DeleteRule to
SetNull and UpdateRule to Cascade, but I get a constraint error on filling
the dataset in my program, I guess because most fields in the child table do
not have parent rows (but I don't want them to have parent rows). How do I
set this up in the dataset schema editor?

Thanks,
Nathan
 
W

W.G. Ryan MVP

I have two tables in a dataset. I want to create a relation between the
two
tables in which the child table can have foreign keys that do not match
primary key fields in the parent table.
--This by definition goes against the definintion of a key unfortunately.

I guess because most fields in the child table do
not have parent rows (but I don't want them to have parent rows).
--Again this is precisely the condition keys are supposed to avoid.

I think you're going to have to roll your own key so to speak, and trap
rowchanging/columnchanging and run validation on that. As far as keys go -
if you're going to have orphan records, all bets are off.
HTH,

Bill

Nathan M said:
When the parent table is updated, I
 
J

Jerry H.

You can set the "Enforceconstraints" property to FALSE on your dataset
object, but as stated by WGRyan, you're going against the nature of
Parent/Child relations which is what the Dataset expects to handle.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top