Hey,
Using linq to select first 9 columns using their index in datatable1 and store the output in another datatable 2.
Any idea?
Hey,
Using linq to select first 9 columns using their index in datatable1 and store the output in another datatable 2.
Any idea?
Hi @Ray_Sha1
How about this expression?
New DataTable → DtOutput
(From d In Dt.AsEnumerable
let ra = d.ItemArray.Take(9).toArray
Select DtOutput.Rows.Add(ra)).CopyToDataTable
Regards
Gokul
Hi @Ray_Sha1 ,
If you want to filter the Datatable to keep only the First 9 Columns, then you can Check the below Expression :
OutputDT = DT.DefaultView.ToTable(false,DT.Columns.Cast(Of DataColumn).Select(Function(x)x.ColumnName.ToString).Take(9).ToArray)
@Gokul001 @supermanPunch
The solution works.
Thanks!
This takes in the whole first datatable
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.