Convert All Columns in DataTable to String

is there a way to convert all the columns in a datatable to string type using an assign activity? If so, how would i go about it? For example i have a datatable with a dynamic number of columns and i want all the columns to be converted to string types

It is much easier to just append .tostring to the values whenever you need to pull information out of the datatable.

If you truly have to convert the datatable info to string (highly do not recommend doing this without a very good reason), then you have to copy the entirety of the column values and convert to string in a new column using the .tostring method for each value. Then you can set the ordinal of the newly created column and delete the old column. You’ll have to do this for every single column - the best way would be using a for each activity and an if statement (if column.datatype = string Then ignore Else convert) or using a linq in your for each collection (dt1.columns.where(not(function (x) x.columns.datatype = string)

Note that any code given is just pseudo code and is not tested - the syntax is likely off

input sample datatable used within the answer:

About the question:
The simplest option to convert a datatable to string is to use the output datatable activity

bringing 1 Row All Columns to a string (Demo here for the first row)

Bringing all Rows All Cols to a String:

About the Motivation:
I agree to @Dave there should be a particular reason to do it. As for Analyzing / Inspection purpose we do use Debugging / watch panel / immediate panel as e.g. showcased in Academy Course Debugging

Find demo XAML here:
ConvertToString_AllCols_1Row_FullDT.xaml (7.3 KB)


Thanks a lot. that did it.

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