Query for dt into string

Query to get the particular column values and add it to a string as semicolon separated value
Input datatable
Column 1,Column2,Column3,Column4
Tin , Success, well done, hello
Tin , failed , well done, welcome
Tin , Success, done, hello
Mai, Partial, Sorry, Hello

String = success;failed;Success;partial

Hi @Demo_User

  1. Initialize Variables:

    • String: outputString = “”
  2. For Each Row:

    • Input: DataTable (your input DataTable)
    • Output: row (of type DataRow)
  3. If (Condition):

    • Condition: Not String.IsNullOrWhiteSpace(row(“Column2”).ToString)
    • This condition checks if the value in “Column2” is not empty.
  4. Assign (inside the “Then” block):

    • To: outputString
    • Value: outputString + row(“Column2”).ToString + “;”
  5. End For Each

  6. Assign (after the “For Each Row” loop):

    • To: outputString
    • Value: outputString.TrimEnd(“;”) // To remove the trailing semicolon
  7. Output (Print the result):

    • Message Box (or any other activity to display the result)
    • Text: outputString

Try the below query to append the column values as per your requirement.

result = String.Join(";", dataTable.AsEnumerable().Select(Function(row) row("Column2").ToString()))



resultString = If(String.IsNullOrEmpty(resultString), row(“Column2”).ToString(), resultString + “;” + row(“Column2”).ToString())

Hey @Demo_User,

You can try using this LINQ expression that follows the query syntax:

assign result = String.Join(“;”,(From row in datatable Select row(“Column2”)))

Assign Activity

left side : StringOutput

right side : String.Join(";", dt.AsEnumerable.Select(Function(row) row("Column2").ToString).ToArray)