?
Solved

DataSet DataRelation

Posted on 2008-06-10
4
Medium Priority
?
2,966 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
[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
  • 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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