473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multiple Key Relations


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
1 5108
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Raed Sawalha | last post by:
I have the following code where Build the relation on DataSet Schema I got the error that Child Has Multiple Tables DataTable LoData = new DataTable("LearningOutcomesDT"); DataTable LoDocData...
2
by: suzanne shelton | last post by:
Help! I have two tables that i am wishing to join that involve a multiple field primary key on the primary table. Primary table: ScheduleHistory SID *PK Schedule *PK Secondary...
1
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because...
0
by: Ron | last post by:
I am trying to create a nested DataList with multiple subcategories listed under each primary category. Unfortunately, I end up with a bunch of multiple SubCategory values after iterating through...
1
by: chris | last post by:
Hi there, I have a dataset with two tables. They both have two columns which are related (sort of a joined key). I know how to create one relation: ds.Relations.Add("myrelation",...
8
by: Jason L James | last post by:
Hi all, does anyone know if I can create a dataview from multiple datatables. My dataset is constructed from four separate tables and then the relationships are added that link the tables...
0
by: Eric Dahnke | last post by:
Dear List, We have a large project with three of the larger components (of the project) being the eventual creation of a Global Product DB and a Global Customer DB and a Global Dealer DB. ...
4
by: Matt Kruse | last post by:
While developing an internal IE6-only webapp, a discussion started about the 'best' way to apply classes to data tables across multiple pages. The two arguments were: 1. Apply a single class to...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.