Solved

DataSet DataRelation

Posted on 2008-06-10
4
2,963 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 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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