I wanted to add all datacolumns from DT A to another DT B (knowing that the columns do not exist in DT B)
I got the famous error “column name does already belong to another datatable”.
As it seems like there is no equivalent to .itemArray (that copies one row to another datatable), I could use foreach row and assign the values rows by rows, but as I might have a looooot of rows I prefer looking for a way with LINQ.
→ What I want: foreach row in a datatable, copy the data in the same index in the same column name but in another datatable.
→ What I have:
I loop in each datacolumn of A, then:
- I create an empty datacolumn in B that has the column name of A
- and I would like to call for this query. But syntaxically I am stuck:
B_dt.AsEnumerable.Select(function(row) row(columnname).ToString = A_dt.Rows(A_dt.Rows.IndexOf(row)).Item(columnName).ToString)
@ppr do you have an idea ?
A.xlsx (9.2 KB)
B.xlsx (8.5 KB)
and I want:
C.xlsx (8.6 KB)
Add dynamically datacolumns.xaml (7.5 KB)