Solved

DataSet DataRelation

Posted on 2008-06-10
4
2,954 Views
Last Modified: 2010-05-18
Hi,

I have a problem to build the data relation in DataSet.  
My DataSet contains two datatable.

Table1 has two foriegn key wich is a pair of unique key.  Table 2 has a value plus those two foriegn key.
I only know to build the single primary key mapping to another primarity between two tables.  
SUCH AS ds.Relations.Add("IsellGroup", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0]);
Please help to resolve this problem.  Thank you.
Sample data
table 1
ID1 ID2
1    2
2   2
1   3
2   5

table 2
ID1  ID2 COL
1      2    5
1     2     6
1     3     8
0
Comment
Question by:power98888
  • 3
4 Comments
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21756637
Use DataColumn array:

ds.Relations.Add("IsellGroup",
  new DataColumn[] {ds.Tables[0].Columns[0], ds.Tables[0].Columns[1]},
  new DataColumn[] {ds.Tables[1].Columns[0], ds.Tables[1].Columns[0]}
);
0
 
LVL 18

Accepted Solution

by:
philipjonathan earned 500 total points
ID: 21756639
Typo-error in my prev post, my apologies

Use DataColumn array:

ds.Relations.Add("IsellGroup",
  new DataColumn[] {ds.Tables[0].Columns[0], ds.Tables[0].Columns[1]},
  new DataColumn[] {ds.Tables[1].Columns[0], ds.Tables[1].Columns[1]}
);
0
 

Author Closing Comment

by:power98888
ID: 31466004
Thank you
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21757576
Thanks for the generous points
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

17 Experts available now in Live!

Get 1:1 Help Now