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
153 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
Comment Utility
yes: the relations are implemented using foreign key constraints, and can hence be reflected in the dataset
0
 

Author Closing Comment

by:kwh3856
Comment Utility
Thanks
0
 
LVL 42

Expert Comment

by:dqmq
Comment Utility
>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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now