Solved

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

Posted on 2007-11-19
4
155 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:kwh3856
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20317806
yes: the relations are implemented using foreign key constraints, and can hence be reflected in the dataset
0
 

Author Closing Comment

by:kwh3856
ID: 31410067
Thanks
0
 
LVL 42

Expert Comment

by:dqmq
ID: 20317827
>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
 
LVL 6

Expert Comment

by:cottsak
ID: 20317852
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

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question