473,834 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).Ta bleName = "DesignSumm ary"
ds.Tables(1).Ta bleName = "FormulaSummary "
ds.Tables(2).Ta bleName = "MaterialSummar y"
ds.Tables(3).Ta bleName = "ItemUsage"
ds.Tables(5).Ta bleName = "UsageSumma ry"
Dim dcDesignSummary Key As DataColumn() =
{ds.Tables(0).C olumns("WorkOrd erID"), ds.Tables(0).Co lumns("DesignID "),
ds.Tables(0).Co lumns("MachineC ode")}
Dim dcFormulaSummar yKey As DataColumn() =
{ds.Tables(1).C olumns("WorkOrd erID"), ds.Tables(1).Co lumns("DesignID "),
ds.Tables(1).Co lumns("MachineC ode")}
Dim dcMaterialSumma ryKey As DataColumn() =
{ds.Tables(2).C olumns("WorkOrd erID"), ds.Tables(2).Co lumns("DesignID "),
ds.Tables(2).Co lumns("MachineC ode")}
Dim dcItemUsageSumm aryKey As DataColumn() =
{ds.Tables(3).C olumns("WorkOrd erID"), ds.Tables(3).Co lumns("DesignID "),
ds.Tables(3).Co lumns("MachineC ode")}
ds.Relations.Ad d("DesignFormul aRelation", dcDesignSummary Key,
dcFormulaSummar yKey, False)
ds.Relations.Ad d("DesignMateri alRelation", dcDesignSummary Key,
dcMaterialSumma ryKey, False)
ds.Relations.Ad d("DesignItemUs eageRelation", dcDesignSummary Key,
dcItemUsageSumm aryKey, False)
Best Regards
Randy
Nov 21 '05 #1
1 5132
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.SqlDa taAdapter(sql, SqlConn)

sql = yadd
Dim DAReportLineIte ms As New SqlClient.SqlDa taAdapter(sql,
SqlConn)

sql = yadda
Dim DALineItemAccou nts As New SqlClient.SqlDa taAdapter(sql,
SqlConn)

DSRptSetup = New DataSet

DAReportNames.F ill(DSRptSetup, "dtReportNames" )
DAReportLineIte ms.Fill(DSRptSe tup, "dtLineItem s")
DALineItemAccou nts.Fill(DSRptS etup, "dtLineItemAcco unts")
Dim dcLINEITEMSumma ryKey As DataColumn() =
{DSRptSetup.Tab les("dtLineItem s").Columns("rp tCntnt_id"),
DSRptSetup.Tabl es("dtLineItems ").Columns("rpt Names_id")}

Dim dcACCOUNTSummar yKey As DataColumn() =
{DSRptSetup.Tab les("dtLineItem Accounts").Colu mns("rptCntnt_i d"),
DSRptSetup.Tabl es("dtLineItemA ccounts").Colum ns("rptNames_id ")}

DSRptSetup.Rela tions.Add("RptT oLineItem",
DSRptSetup.Tabl es("dtReportNam es").Columns("r ptNames_id"),
DSRptSetup.Tabl es("dtLineItems ").Columns("rpt Names_id"))
DSRptSetup.Rela tions.Add("Line ItemToAccnts",
dcLINEITEMSumma ryKey, dcACCOUNTSummar yKey, 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).Ta bleName = "DesignSumm ary"
ds.Tables(1).Ta bleName = "FormulaSummary "
ds.Tables(2).Ta bleName = "MaterialSummar y"
ds.Tables(3).Ta bleName = "ItemUsage"
ds.Tables(5).Ta bleName = "UsageSumma ry"
Dim dcDesignSummary Key As DataColumn() =
{ds.Tables(0).C olumns("WorkOrd erID"), ds.Tables(0).Co lumns("DesignID "), ds.Tables(0).Co lumns("MachineC ode")}
Dim dcFormulaSummar yKey As DataColumn() =
{ds.Tables(1).C olumns("WorkOrd erID"), ds.Tables(1).Co lumns("DesignID "), ds.Tables(1).Co lumns("MachineC ode")}
Dim dcMaterialSumma ryKey As DataColumn() =
{ds.Tables(2).C olumns("WorkOrd erID"), ds.Tables(2).Co lumns("DesignID "), ds.Tables(2).Co lumns("MachineC ode")}
Dim dcItemUsageSumm aryKey As DataColumn() =
{ds.Tables(3).C olumns("WorkOrd erID"), ds.Tables(3).Co lumns("DesignID "), ds.Tables(3).Co lumns("MachineC ode")}
ds.Relations.Ad d("DesignFormul aRelation", dcDesignSummary Key, dcFormulaSummar yKey, False)
ds.Relations.Ad d("DesignMateri alRelation", dcDesignSummary Key, dcMaterialSumma ryKey, False)
ds.Relations.Ad d("DesignItemUs eageRelation", dcDesignSummary Key, dcItemUsageSumm aryKey, 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
1016
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 = new DataTable("LearningOutcomesDocDT"); da = new SqlDataAdapter(BuildSQLQuery(BookId,queryType.LOBook),oSql); da.Fill(LoData); ds.Tables.Add(LoData); da = new SqlDataAdapter(BuildSQLQuery(BookId,queryType.LODoc),oSql);
2
10654
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 table: Transactions SID Schedule ...
1
1805
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 after running the code the relations don't show in the relations window. However when I enter data in an underlying table I get referential integrity error messages so the relations does actually exist. The created relations do show in the relations...
0
984
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 the loop. My code is as follows: //**************************************************************** for(int i=0;i<=cat.Count-1;i++) {
1
5087
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", ds.Tables.Columns, ds.Tables.Columns);
8
10422
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 together. To make data entry easier I would like to combine selected columns from the four tables onto a single dataview that could be used as the datasource for a datagrid control. The distinct updates, insert ans delete
0
954
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. Because of certain legacy issues, the schema has evolved to be one large application specific schema containing product, customer, and dealer tables. A better design would be three separate databases (and we can pull them apart easily enough), but...
4
4706
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 each table. That class (possibly in combination with other classes on child elements) controls every part of the table - layout, colors, fonts, etc. Example: class="data" PROS: Easier to standardize, less specificity confusion, everything is...
11
3691
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) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
0
9646
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10793
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10510
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.