// <Summary>
// Merge multiple tables with the same structure
// <Param name = "DataSet"> </param>
/// </Summary>
// <Returns> DataTable </returns>
Function
1 public DataTable GetAllDataTable (DataSet ds)
2 {
3 DataTable newDataTable = ds. Tables [0]. Clone (); // create a new table Clone to have a table schema.
4 object [] objArray = new object [newDataTable. Columns. Count]; // defines the values of a row in the table in an array of objects with the same number of Columns as the table.
5 for (int I = 0; I <ds. Tables. Count; I ++)
6 {
7 for (int j = 0; j <ds. Tables [I]. Rows. Count; j ++)
8 {
9 ds. Tables [I]. Rows [j]. ItemArray. CopyTo (objArray, 0); // stores the values of a row in an array.
10 newDataTable. Rows. Add (objArray); // Add the array value to the new table.
11}
12}
13 return newDataTable; // return the new table.
14}