Combine 5 columns of a datatable into a single column separated by comma without looping

Hi I want to Combine 5 columns of a datatable into a single column separated by comma without looping

Input

image

Hi,

Can you try the following sample?

dtResult = dt.AsEnumerable.Select(Function(r) dtResult.LoadDataRow({String.Join(",",r.ItemArray)},False)).CopyToDataTable()

Sample20230718-2L.zip (8.6 KB)

Regards,

You have to loop. Any solution will loop.

  1. Assign activity: dataTable = (your DataTable)

  2. Assign activity: concatenatedStrings = String.Join(“,”, dataTable.AsEnumerable().Select(Function(row) row(“Column1”).ToString() + “,” + row(“Column2”).ToString() + “,” + row(“Column3”).ToString() + “,” + row(“Column4”).ToString() + “,” + row(“Column5”).ToString()))

  3. Log Message activity: concatenatedStrings

Thank you! @Yoichi

It’s working perfectly.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.