Select "Both Relation and Foreign Key Constraint" when creating relationship in VS Dataset designer.

MS VS Dataset Designer  allows to create a relationship (a DataRelation object) that maintains information about parent-child records in two data tables in a dataset using Relation Dialog Box.
It has option to specify type of relationship:
Both Relation and Foreign Key Constraint

Creates both a relation and foreign key constraint (see below for descriptions).

Foreign Key Constraint Only

A ForeignKeyConstraint restricts the action performed when a value in a column (or columns) is either deleted or updated.

Relation Only

A DataRelation is used to relate two DataTable objects to each other through DataColumn objects.

The default is "Relation Only", and it causes problems, if your code  modifies primary key of referenced table and you expected cascade updates.
 
Based on my experience, it is better to use "Both Relation and Foreign Key Constraint" and specify 
Update and Delete rules as  Rule.Cascade .

May be the VS Relation Dialog Box.should not specify the defaut, but force developer to make consious desision.

posted @ Saturday, August 16, 2008 2:05 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345