?
Solved

Creating relationship between tables in a Dataset based on multiple columns.

Posted on 2005-04-12
4
Medium Priority
?
417 Views
Last Modified: 2010-04-23
Hi,

I looking for the syntax to create a relationship between tables in a dataset based on multiple columns. Please correct the following sample code.

Private Sub CreateRelation()
    ' Get the DataColumn objects from two DataTable objects in a DataSet.
    Dim parentCol As DataColumn
    Dim childCol As DataColumn
    ' Code to get the DataSet not shown here.
    parentCol = DataSet1.Tables("Customers").Columns("CustID","Code")
    childCol = DataSet1.Tables("Orders").Columns("CustID","Code")
    ' Create DataRelation.
    Dim relCustOrder As DataRelation
    relCustOrder = New DataRelation("CustomersOrders", parentCol, childCol)
    ' Add the relation to the DataSet.
    DataSet1.Relations.Add(relCustOrder)
 End Sub

0
Comment
Question by:Dileepgn
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 total points
ID: 13763684
DataSet1.Tables("Customers".Columns only accept one parameter.

If you want to create a relationship on multiple columns, you need to create a datacolumn array. Read this article, it will help you.

http://www.dotnet247.com/247reference/msgs/8/44885.aspx

Regards,

Jeffrey
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 13941552
Just wonder if my comment ever helped you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

850 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