|
-
Apr 3rd, 2007, 04:13 AM
#1
Thread Starter
Frenzied Member
[2005] Fill a datatable with the contents of 3 other data tables
Hello,
I have one data table with fields SerialNo, manufacturer, and model. Called AllParts.
I have 3 other data tables (software, components, equipment) that have those same fields plus some extra fields.
I want to fill this allParts with the serialNo, manufacturer, and model from the other tables.
So allParts will contain rows from software, components, equipment
a bit like copying all the contents from the 3 tables and merging them into a single data table called allParts.
Can anyone help me with this.
Many thanks,
Steve
-
Apr 3rd, 2007, 04:25 AM
#2
Re: [2005] Fill a datatable with the contents of 3 other data tables
Just loop through the rows of a source table and call the LoadDataRow method of the destination table. Do that three times and you're done.
-
Apr 3rd, 2007, 04:58 AM
#3
Thread Starter
Frenzied Member
Re: [2005] Fill a datatable with the contents of 3 other data tables
Hello,
Not sure which method is better but I did it this way.
Code:
dtAllCustomerPart.Merge(dtCustomersSoftware)
dtAllCustomerPart.Merge(dtCustomersComponents)
dtAllCustomerPart.Merge(dtCustomersEquipment)
Thanks for any advice on this,
-
Apr 3rd, 2007, 05:02 AM
#4
Re: [2005] Fill a datatable with the contents of 3 other data tables
No advice just a question if you don't mind (I'm learning this and need to do something similar).
Did you create 3 new datasets and merge them into a summary dataset? Or are they tables? I'm confused by all this and am just trying to get it straight in my head.
-
Apr 3rd, 2007, 07:05 AM
#5
Re: [2005] Fill a datatable with the contents of 3 other data tables
 Originally Posted by steve_rm
Hello,
Not sure which method is better but I did it this way.
Code:
dtAllCustomerPart.Merge(dtCustomersSoftware)
dtAllCustomerPart.Merge(dtCustomersComponents)
dtAllCustomerPart.Merge(dtCustomersEquipment)
Thanks for any advice on this,
If that works then that would definitely be a better way. I wasn't aware that you could merge tables with different schema. I guess just the corresponding columns are used and the rest are ignored.
-
Apr 3rd, 2007, 10:03 AM
#6
Thread Starter
Frenzied Member
Re: [2005] Fill a datatable with the contents of 3 other data tables
Hello Stimbo,
I used 1 dataset and 4 data tables. The dataset can hold many data tables.
I merged 3 data tables into 1 datatable.
Hope this helps,
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|