Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to
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 on Saturday, August 16, 2008 2:05 PM Visual Studio/TFS/git | Back to top

Comments on this post: Select "Both Relation and Foreign Key Constraint" when creating relationship in VS Dataset designer.

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: