Values of first row from Datatable

How do i get the first row of values from a datatable and concatenate them?

e.g. “this” , “is” , “a” , “datarow”
the DT has 4 columns, and the above values are from the first row.

Use a for each row in your datatable, inside the for each concatenat the row values anyway you like.
For example using assign:
To: strConcatenatedText
Value: row(0) & " " & row(1) & " " & row(2) & " " & row(3)

what if the number of columns differ? sometimes might be 4 somtimes might be 5?

Okay, so if you have a dynamic number of columns (or you don’t know how many columns you will have) then you can use yourdatatable.Columns.Count to get the number of columns.
Then use a counter inside a Do while counter < yourdatatble.columns.Count and then assign
to: strConcatenatedText
Value: strConcatenatedText & " " & row(counter)

counter = counter + 1

First you need to fetch your required datarow from datatable.

dr = datatable.Rows.Item(0)

Then, you can concatenate using String.Join function which will return your required output.

strValue = String.Join(" ", dr.ItemArray)

Mark it as solution if this post serves your purpose.
Cheers,
JDoshi

1 Like

ReadFirstRow_Concatinate.zip (22.4 KB)
Hi,
Please find the attached sample workflow file

Mark as solution if it works

1 Like

Thank you, @Venugopal24, for your contribution. You made my day, and I am no longer stuck in the furher development of my current project :100: