DataRelation - Many-toMany allowable?

D

Dave Powlin

Is there a way to add multiple relations to two DataTable in a DataSet?

Here is the problem....

Table 1 contains aggregated data grouped a time_period and a network_key.

Table 2 contains the individual details from the source table in Table 1.
Table 2 has a 3 coulm key of physician_id, time_period and network_key.

When you expand the top level (Table 1), I want to show the details by
physician key. Pretty standard fare, imo. I need to join on time_period and
network_key, and the physician_id records should be unique.

HOW DO I DO THIS? I try adding 2 DataRelations (one on each column) and it
fails after the first one because it isn't unique. I created both then tried
adding them as an array but, once again, I was foiled.

I noticed a handful of other have posted a similar question in the past and
there was not a single response. Can someone please tell me if this is
something I can do? It really seems pretty straightforward. This is nothing
but a multi-column join.

Thanks.

DP
 
D

Dave Powlin

Is there a way to add multiple relations to two DataTable in a DataSet?
Here is the problem....

Table 1 contains aggregated data grouped a time_period and a network_key.

Table 2 contains the individual details from the source table in Table 1.
Table 2 has a 3 coulm key of physician_id, time_period and network_key.

When you expand the top level (Table 1), I want to show the details by
physician key. Pretty standard fare, imo. I need to join on time_period and
network_key, and the physician_id records should be unique.

HOW DO I DO THIS? I try adding 2 DataRelations (one on each column) and it
fails after the first one because it isn't unique. I created both then tried
adding them as an array but, once again, I was foiled.

I noticed a handful of other have posted a similar question in the past and
there was not a single response. Can someone please tell me if this is
something I can do? It really seems pretty straightforward. This is nothing
but a multi-column join.

Thanks.

DP

This MSDN example does not work:

Private Sub CreateRelation()
' Get the DataColumn objects from two DataTable objects in a DataSet.
Dim parentCols() As DataColumn
Dim childCols() As DataColumn
' Code to get the DataSet not shown here.
parentCols(0) = DataSet1.Tables("Customers").Columns("CustID")
parentCols(1) = DataSet1.Tables("Customers").Columns("OrdID")

childCols(0) = DataSet1.Tables("Orders").Columns("CustID")
childCols(1) = DataSet1.Tables("Orders").Columns("OrdID")
' Create DataRelation.
Dim CustOrderRel As DataRelation
CustOrderRel = New DataRelation("CustomersOrders", parentCols,
childCols)
' Add the relation to the DataSet.
DataSet1.Relations.Add(CustOrderRel)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top