By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,954 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,954 IT Pros & Developers. It's quick & easy.

Multiple Key Relations

P: n/a

How do I create a relationship on muliple columns in an untyped dataset.

Why does this not work.

da.Fill(ds)
ds.Tables(0).TableName = "DesignSummary"
ds.Tables(1).TableName = "FormulaSummary"
ds.Tables(2).TableName = "MaterialSummary"
ds.Tables(3).TableName = "ItemUsage"
ds.Tables(5).TableName = "UsageSummary"
Dim dcDesignSummaryKey As DataColumn() =
{ds.Tables(0).Columns("WorkOrderID"), ds.Tables(0).Columns("DesignID"),
ds.Tables(0).Columns("MachineCode")}
Dim dcFormulaSummaryKey As DataColumn() =
{ds.Tables(1).Columns("WorkOrderID"), ds.Tables(1).Columns("DesignID"),
ds.Tables(1).Columns("MachineCode")}
Dim dcMaterialSummaryKey As DataColumn() =
{ds.Tables(2).Columns("WorkOrderID"), ds.Tables(2).Columns("DesignID"),
ds.Tables(2).Columns("MachineCode")}
Dim dcItemUsageSummaryKey As DataColumn() =
{ds.Tables(3).Columns("WorkOrderID"), ds.Tables(3).Columns("DesignID"),
ds.Tables(3).Columns("MachineCode")}
ds.Relations.Add("DesignFormulaRelation", dcDesignSummaryKey,
dcFormulaSummaryKey, False)
ds.Relations.Add("DesignMaterialRelation", dcDesignSummaryKey,
dcMaterialSummaryKey, False)
ds.Relations.Add("DesignItemUseageRelation", dcDesignSummaryKey,
dcItemUsageSummaryKey, False)
Best Regards
Randy
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You may have better luck if you individually fill each table - I could
never get the "multi fill" thing to work to begin with.

the following worked for me with trees nested 3 nodes deep...

Dim sql As String
Dim DSRptSetup As DataSet

sql = ya
Dim DAReportNames As New SqlClient.SqlDataAdapter(sql, SqlConn)

sql = yadd
Dim DAReportLineItems As New SqlClient.SqlDataAdapter(sql,
SqlConn)

sql = yadda
Dim DALineItemAccounts As New SqlClient.SqlDataAdapter(sql,
SqlConn)

DSRptSetup = New DataSet

DAReportNames.Fill(DSRptSetup, "dtReportNames")
DAReportLineItems.Fill(DSRptSetup, "dtLineItems")
DALineItemAccounts.Fill(DSRptSetup, "dtLineItemAccounts")
Dim dcLINEITEMSummaryKey As DataColumn() =
{DSRptSetup.Tables("dtLineItems").Columns("rptCntn t_id"),
DSRptSetup.Tables("dtLineItems").Columns("rptNames _id")}

Dim dcACCOUNTSummaryKey As DataColumn() =
{DSRptSetup.Tables("dtLineItemAccounts").Columns(" rptCntnt_id"),
DSRptSetup.Tables("dtLineItemAccounts").Columns("r ptNames_id")}

DSRptSetup.Relations.Add("RptToLineItem",
DSRptSetup.Tables("dtReportNames").Columns("rptNam es_id"),
DSRptSetup.Tables("dtLineItems").Columns("rptNames _id"))
DSRptSetup.Relations.Add("LineItemToAccnts",
dcLINEITEMSummaryKey, dcACCOUNTSummaryKey, False)
then fill trees...

Randy Fraser wrote:
How do I create a relationship on muliple columns in an untyped dataset.
Why does this not work.

da.Fill(ds)
ds.Tables(0).TableName = "DesignSummary"
ds.Tables(1).TableName = "FormulaSummary"
ds.Tables(2).TableName = "MaterialSummary"
ds.Tables(3).TableName = "ItemUsage"
ds.Tables(5).TableName = "UsageSummary"
Dim dcDesignSummaryKey As DataColumn() =
{ds.Tables(0).Columns("WorkOrderID"), ds.Tables(0).Columns("DesignID"), ds.Tables(0).Columns("MachineCode")}
Dim dcFormulaSummaryKey As DataColumn() =
{ds.Tables(1).Columns("WorkOrderID"), ds.Tables(1).Columns("DesignID"), ds.Tables(1).Columns("MachineCode")}
Dim dcMaterialSummaryKey As DataColumn() =
{ds.Tables(2).Columns("WorkOrderID"), ds.Tables(2).Columns("DesignID"), ds.Tables(2).Columns("MachineCode")}
Dim dcItemUsageSummaryKey As DataColumn() =
{ds.Tables(3).Columns("WorkOrderID"), ds.Tables(3).Columns("DesignID"), ds.Tables(3).Columns("MachineCode")}
ds.Relations.Add("DesignFormulaRelation", dcDesignSummaryKey, dcFormulaSummaryKey, False)
ds.Relations.Add("DesignMaterialRelation", dcDesignSummaryKey, dcMaterialSummaryKey, False)
ds.Relations.Add("DesignItemUseageRelation", dcDesignSummaryKey, dcItemUsageSummaryKey, False)
Best Regards
Randy


Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.