I have two datatables. Each has three columns, the two of them have the same name. However one column in table1 is “Desc”, in table2 is named as “Descr”.
How to merge them together?
Thanks.
EDIT
The two datatables come from two datagridview.
DataRow dr = dg1.Newrow()
foreach (DataRow row in dt2.Rows)
{
dr[0] = row[0];
dr[1] = row[1];
dr[2] = row[2];
dg1.Rows.Add(dr);
}
dg1 is a datagridview. dt2 is just a datatable.
Use the
MergemethodYou can find some sample code here along with docs.
http://msdn.microsoft.com/en-us/library/system.data.datatable.merge.aspx
Note: You may have to rename your Desc column just before you merge the tables: