Convert Datatype of a datatable

Hi Guys,

Is there any easier way to convert data type of all values in a data table to string.
In my workflow, the BOT is reading an excel file and storing the values in datatable as system.object by default . I want to merge this datatable to another datatable which has columns as string.

I tried to look into other help topics but could not find a solution, can someone help please.

@somesh.r.nagar

convert dt to string

Hi @somesh.r.nagar,

If you want to convert the entire data table variable to string you can use output data table activity.
If you want to convert the rows then first clone your dt using
dtCloned = dt.clone() in an assign activity.
then use the following linq

dt.AsEnumerable().Select(Function(row) dtCloned.NewRow().ItemArray = row.ItemArray.Select(Function(x) x.ToString()).ToArray()).CopyToDataTable()

this will create a new data table with rows converted to string.

Let me know if you have any questions.

Getting error

error BC31080: Operator ‘=’ is not defined for types ‘Object()’ and ‘String()’. Use ‘Is’ operator to compare two reference types

It pertains to Output Datatable activity, unfortunately this activity does not help me

Please try this linq

dt.AsEnumerable().Select(Function(row) dtCloned.LoadDataRow(row.ItemArray.Select(Function(x) If(x IsNot Nothing, x.ToString(), Nothing)).ToArray(), False)).CopyToDataTable()