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

Converion of DataSet to a flat DataTable

Hi,
What is the best way to convert DataSet containing parent child relations
into a single DataTable (Flatten)

For eg:-
DataSet will contain Tables as follows
Tbl_Parent( Parent_Id, Parent_Name)
Tbl_Child( Child_Id, Child_Name, Parent_Id)
Tbl_ChildOfChild(ChildOfChild_Id, ChildOfChild.Name, ChildOfChild.Child_Id)

Sample data with respect to the above columns
Tbl_Parent
( Parent_Id, Parent_Name)
1 "A"
----------------------------------------------------------------------------
----------------

Tbl_Child
(Child_Id, Child_Name, Parent_Id)
1 "a" 1
2 "b" 1
3 "c" 1
----------------------------------------------------------------------------
----------------

Tbl_ChildOfChild
(ChildOfChild_Id, ChildOfChild.Name, ChildOfChild.Child_Id)
1 "aa" 1
2 "bb" 1
1 "aa" 2
2 "bb" 2
3 "cc" 2
1 "aa" 3
----------------------------------------------------------------------------
----------------
Tbl_ChildOfChild
1 "aa"
2 "bb"

I would like to get the data into a single DataTable
as follows;

1 "A" 1 "a" 1 "aa"
1 "A" 1 "a" 2 "bb"
1 "A" 2 "b" 1 "aa"
1 "A" 2 "b" 2 "bb"
1 "A" 2 "b" 3 "cc"
1 "A" 3 "c" 1 "aa"
Any suggestions??
Shibu

Nov 17 '05 #1
1 2013
Hi Shibu,

You have to do it manually (using loops).
Or read from database using join stataments.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Shibu" <sh*****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Hi,
What is the best way to convert DataSet containing parent child relations
into a single DataTable (Flatten)

For eg:-
DataSet will contain Tables as follows
Tbl_Parent( Parent_Id, Parent_Name)
Tbl_Child( Child_Id, Child_Name, Parent_Id)
Tbl_ChildOfChild(ChildOfChild_Id, ChildOfChild.Name,
ChildOfChild.Child_Id)

Sample data with respect to the above columns
Tbl_Parent
( Parent_Id, Parent_Name)
1 "A"
----------------------------------------------------------------------------
----------------

Tbl_Child
(Child_Id, Child_Name, Parent_Id)
1 "a" 1
2 "b" 1
3 "c" 1
----------------------------------------------------------------------------
----------------

Tbl_ChildOfChild
(ChildOfChild_Id, ChildOfChild.Name, ChildOfChild.Child_Id)
1 "aa" 1
2 "bb" 1
1 "aa" 2
2 "bb" 2
3 "cc" 2
1 "aa" 3
----------------------------------------------------------------------------
----------------
Tbl_ChildOfChild
1 "aa"
2 "bb"

I would like to get the data into a single DataTable
as follows;

1 "A" 1 "a" 1 "aa"
1 "A" 1 "a" 2 "bb"
1 "A" 2 "b" 1 "aa"
1 "A" 2 "b" 2 "bb"
1 "A" 2 "b" 3 "cc"
1 "A" 3 "c" 1 "aa"
Any suggestions??
Shibu

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shibu | last post by:
Hi, What is the best way to convert DataSet containing parent child relations into a single DataTable (Flatten) For eg:- DataSet will contain Tables as follows Tbl_Parent( Parent_Id,...
3
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. ...
15
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
2
by: Jim Heavey | last post by:
Hello I turned Option Strict on and after I did, I am getting an error of "Option Explicit does not allow late binding". OK great, now it is time to learn how to create a strongly typed dataset....
5
by: Roy Lawson | last post by:
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this. My only problem now is...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
3
by: BillJohnson4 | last post by:
Experts: I have built an in-memory dataset by parsing a flat file so that I can display the contents onto a datagrid. The Microsoft C# .NET System.Data.DataTable.Select() method allows me to...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
3
by: Tom | last post by:
I have a dataTable being returned from my datalayet, I need to convert it to a dataSet so I can do some data manipulation to it prior to populating my datagrid. How can I convert the datatable to a...
2
by: id10t error | last post by:
Hello, I am working on a project where I read in data from a flat file using a dataset .The program than lets the user scan the barcode. The problem is when the person scans a barcode on another...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.