If I use SQL 2005 to setup the relations between tables, will the relationships be maintained when I create a dataset using the tables?

I was wandering if I built relations in the database in SQL 2005, does the relations flow through when you setup a dataset in C#?

Thanks
Kenny
kwh3856Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
yes: the relations are implemented using foreign key constraints, and can hence be reflected in the dataset
0
 
kwh3856Author Commented:
Thanks
0
 
dqmqCommented:
>I was wandering if I built relations in the database in SQL 2005, does the relations flow through when you setup a dataset in C#?

You can add FK relations to the dataset and they will be enforced as you make changes to the dataset.  However, they do not appear automatically just because they are defined in the database.
0
 
cottsakCommented:
provided the dataset targets more than one table where there are relationships.
for example if table A and B are related but C is not, if the dataset includes A and C then the relationship to B will not be maintained because it';s not in the scope.

use the Visual Studio visual dataset designer and drag the tables from the database in the Server Explorer pane to the dataset designer - if two tables have a relationship then the designer will create the relationship after you drag the tables on.

BE AWARE that if you modify the relationships in the DB, the dataset (which is really xml metadata) will NOT update automatically. you need to open up the designer again and edit and save the schema of a table for Visual Studio to re-query the database for the relationship changes. (hopefully this will be addresses in VS2008)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.