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
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 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