How to get the values of a data column to a string

How to get the values of a data column to a string.

Column1 Column2
ab er
cd er
ef er

I want the the values of the column ‘Column1’, So that my output looks like “ab,cd,ef”

Thanks in advance.

May be there is a easy way @MariaJosephina,

But this will also work.
Here are some steps

  1. Loop through data table and get the value of the required column using row(“column1”).tostring
  2. Create a new variable of type string and append the value of row(“column1”).tostring to the string as string = string + row(“column1”).tostring
1 Like

@MariaJosephina
You can get value from table like
Table1.(rowindex).item(columnindex).tostring
Or
Iterates datatable through for each activity
Rowitem.item(columnindex). tostring

Thanks

1 Like

I need without for each iterattion

Then
Table1.(rowindex).item(columnindex).tostring
Like
Table1.(0).item(0).tostring ,Table1.(1).item(0).tostring …so on

Do onething,

Filter the datatable like, keep only the required column in the existing datatable using Filter Data Table activity and store in a new data table

then, use Output Data Table activity which will return you the data table in a string @MariaJosephina

2 Likes

The Classical Way:
Iterate with for each row and add first column to a collection of type List(Of String)

The one liner
define a variable: eg. name: StringListVariable type: List(Of String)
Use an assign activity
To: sl,
Value: YourDataTableVariable.AsEnumerable.Select(Function (row) row.Field(Of String)(“YourColName”)).toList

Later you can easy bring the string list to flatten string eg. String.Join(“,”,StringListVariable.ToArray)

For the one liner way make sure System.Data.DataSetExtensions is imported
Have a look here:

5 Likes

Thanks it worked

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