473,414 Members | 1,888 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,414 software developers and data experts.

How to combine two DataTables with different schemas?

I am working with C# code on an ASP.NET Page, and am having trouble with my DataTables. I have populated two tables from sprocs in my Database - the first one looks like this:
Table1:
ID Name
id1 category1
id2 category2

my second table has multiple rows, but the relevant ones are:
Table2:
Name ID ParentID
row1 id4 id1
row2 id5 id1
row3 id6 id2

I want to display a table that will look something like this (pseudocode):

foreach (t1row in Table1)
{display t1row[name]
foreach (t2row in Table2)
{ if (t2row[parentID] = t1row[id])
{display t2row[all columns]}
}
}

I have been trying to add or import these rows into a Display Table, or View, or even dataset, and it is not working. Any suggestions?

Thank you!
--student intern
Feb 12 '08 #1
1 4045
dip_developer
648 Expert 512MB
I am working with C# code on an ASP.NET Page, and am having trouble with my DataTables. I have populated two tables from sprocs in my Database - the first one looks like this:
Table1:
ID Name
id1 category1
id2 category2

my second table has multiple rows, but the relevant ones are:
Table2:
Name ID ParentID
row1 id4 id1
row2 id5 id1
row3 id6 id2

I want to display a table that will look something like this (pseudocode):

foreach (t1row in Table1)
{display t1row[name]
foreach (t2row in Table2)
{ if (t2row[parentID] = t1row[id])
{display t2row[all columns]}
}
}

I have been trying to add or import these rows into a Display Table, or View, or even dataset, and it is not working. Any suggestions?

Thank you!
--student intern
from your query I understood that you want all the Name from Table1 and all the records from Table2 where Table2.ParentID =Table1.ID ...right???

these two query will produce different number of records.....why do you want to join them....and on what basis......
execute two different queries........
1.select Name from Table1
2.select Name, ID, ParentID from Table2 inner join Table1 on Table2.ParentID =Table1.ID
Feb 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is...
0
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is...
0
by: wapsiii | last post by:
How is it possible to combine/join/merge two identical (schema) datatables into a new datatable? /M
3
by: don | last post by:
I have written a program to hold a sales contact db. It is written in c# express. an update is sent from head office in xl format, i need to import only the new rows to an access database. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.