byrmol Blog

Garbage

Copying DataTables

The project I am on sources data from both Mainframe (DB2)and SQL Server. The data is delivered to the front end via web service methods as an XML stream.

In most situations all the data "joining" is already done in the middle tier, but for a particular use case, the front end must manage 2 different XML streams (one from DB2 and the other from SQL)

First thought was to use the XML classes in .NET but another easier option was to use DataSets.

Each stream is loaded into a data set via the LoadXML method. The data schemas are too different to attempt any sort of merge operation so the creation of a new DataSet is called for.

Using the SELECT method with a "WHERE" clause, we can pull the necessary data from each DataTable in each DataSet and add these to our new data set.

A "gotcha" is if you have to add the entire table from one dataset to the other. The DataTable must be copied using the Copy method. The Clone method will not cut it and produces a "Cannot add a DataTable that is already part of another DataSet."

This is a short term solution while we wait for the middler tier to combine them for us.

Legacy Comments


Cake Boy
2004-07-21
re: Copying DataTables
If you want the whole table with a where clause why not use Where 1=1?

Ajith
2006-01-13
re: Copying DataTables
good

Uma
2006-03-30
re: Copying DataTables
thanks

imranali
2006-06-28
re: Copying DataTables
this website is providing great help for programmers who ever in beginning og realtime programming stage