i have 1st excel with 6 columns and 2nd excel with 15 columns(6 colums as in 1st excel with same column name)
i need to copy data from 1st to 2nd to all specific column
Can anyone help with the linq?
You can try this LINQ
Get the dtMerged initialised like this before.
dtMerged = dt1.AsEnumerable().Concat(dt2.AsEnumerable()).CopyToDataTable()
dtMerged = (From row In dt1.AsEnumerable()
Select dt2.Rows.Add(row.ItemArray)).CopyToDataTable()
Hey Ashok
dt1 will have 7 columns
dt2 will have 5 columns(5 other columns wil have some data in it and 7 columns will be of same name as in dt1)
from dt1 we need to paste specific 5 column values to dt 2
If still not resolved can you please share the file with dummy data and the expected output?
dt1,
t
dt2, which already has data in it,
![]()
ask is to concat dt1 data(only 5 colums) with dt2 on basis of column names and then we need to apply filter
i tried merge data table but got error as - both the REPORTDATE column have conflicting properties
so want LINQ
I see there are slight changes in column names. Can you rely on column index?
index may change as 1 data is generate from other application
but we can use linq and specify column names of both datatable right?
Yes we can. If possible share the file in direct message, I will try to help whatever I can.