Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, January 18, 2014 12:37 AM
Hi list,
I have two datatable dt1 and dt2, do you know how I can union them together?
DataTable dt1 = new DataTable();
dt1.Columns.Add("col1",Typeof(int));
dt1.Rows.Add(1);
dt1.Rows.Add(2);
DataTable dt2 = new DataTable();
dt2.Columns.Add("col1",Typeof(int));
dt2.Rows.Add(3);
dt2.Rows.Add(4);
Now I want to add dt2 to dt1, which results dt1 as follows:
dt1 where col1 has values of 1,2,3,4
thanks
Arvin
All replies (1)
Saturday, January 18, 2014 6:26 AM âś…Answered
Hi,
You can make use of the Merge method.
sample:
dt1.Merge(dt2);
The merge method will merge the rows from datatable1 and datatable2. In above case the rows in dt2 will be merged into dt1.
SRIRAM