[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DataSet DataRelation

Posted on 2008-06-10
4
Medium Priority
?
2,973 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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…

656 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