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)


 
 
 
Please add 3 and 3 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910