Solved

How to append another datatable to an existing dataset

Posted on 2008-10-23
3
726 Views
Last Modified: 2013-11-07
hi there,
I have an exisitng datatset with two datatables combined. Now the need to add another datatable makes me confuse on how to add it to the existing relationship. below is the code i have for the relacionship how can i add the Lawyer datatable to the dsaddresses dataset?

Thanks,
jsctehcy
Public Shared Function GetAddresses(ByVal Case_Number As String) As DataSet
 

            'datatables repository

            Dim dsAddresses As DataSet = New DataSet

            Dim Relation As DataRelation
 

            'Create the Address datatable

            dsAddresses.Tables.Add(GetAddress(Case_Number))

            dsAddresses.Tables(0).TableName = "Address"
 

            'Create Registered Agent Datatable

            dsAddresses.Tables.Add(GetRegisteredAgent(Case_Number))

            dsAddresses.Tables(1).TableName = "RegisterAgent"
 

            'Create Lawyer Datatable

            dsAddresses.Tables.Add(GetAttorney(Case_Number))

            dsAddresses.Tables(2).TableName = "Lawyer"
 

            'create relation betwen Address and Registered Agent tables

            Relation = New DataRelation("CASE_NUMBER", dsAddresses.Tables("Address").Columns("CASE_NUMBER"), dsAddresses.Tables("RegisterAgent").Columns("CASE_NUMBER"))

            dsAddresses.Relations.Add(Relation)
 

            'return the datatables repository

            Return dsAddresses
 

        End Function

Open in new window

0
Comment
Question by:jsctechy
  • 2
3 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
Comment Utility
It looks like you just need to create another relation to hook up the Lawyer table

Relation = New DataRelation("CASE_NUMBER_Lawyer", dsAddresses.Tables("Address").Columns("CASE_NUMBER"), dsAddresses.Tables("Lawyer").Columns("CASE_NUMBER"))

dsAddresses.Relations.Add(Relation)
0
 
LVL 1

Author Comment

by:jsctechy
Comment Utility
ok you got me all confuse can you post the entire code?

why do i have relation twice that does not seems to be right?
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
Comment Utility
You need 2 relations, one that connects address and registeredagent and a second one to connect Address to Lawyer


  'datatables repository

            Dim dsAddresses As DataSet = New DataSet

            Dim Relation As DataRelation

 

            'Create the Address datatable

            dsAddresses.Tables.Add(GetAddress(Case_Number))

            dsAddresses.Tables(0).TableName = "Address"

 

            'Create Registered Agent Datatable

            dsAddresses.Tables.Add(GetRegisteredAgent(Case_Number))

            dsAddresses.Tables(1).TableName = "RegisterAgent"

 

            'Create Lawyer Datatable

            dsAddresses.Tables.Add(GetAttorney(Case_Number))

            dsAddresses.Tables(2).TableName = "Lawyer"

 

            'create relation betwen Address and Registered Agent tables

            Relation = New DataRelation("CASE_NUMBER", dsAddresses.Tables("Address").Columns("CASE_NUMBER"), dsAddresses.Tables("RegisterAgent").Columns("CASE_NUMBER"))

            dsAddresses.Relations.Add(Relation)
 

'creates relation between address and lawyer tables 

Relation = New DataRelation("CASE_NUMBER_Lawyer", dsAddresses.Tables("Address").Columns("CASE_NUMBER"), dsAddresses.Tables("Lawyer").Columns("CASE_NUMBER"))

dsAddresses.Relations.Add(Relation)
 

            'return the datatables repository

            Return dsAddresses

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now