?
Solved

How to append another datatable to an existing dataset

Posted on 2008-10-23
3
Medium Priority
?
768 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22789226
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
ID: 22789416
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 2000 total points
ID: 22789478
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 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