Convert Dic <String, Datatable> to Dic <Of String, String>


I have a Dictionary<of String, Datatable>

{“1”, Datatable}
{“2”, Datatable}
{“3”, Datatable}

I would like to save the 3rd Datatable to another Datatable<Of String, String>.

Any way we can do it without for each?


1 Like

Sorry unable to get it clearly. Kindly explain please @wonderingnoname

Hello! I have a variable with type of Dictionary<String, DataTable> this dictionary have 3 items in it.

{“1”, Datatable}
{“2”, Datatable}
{“3”, Datatable}

I need to convert the 3rd item to a Dictionary <String,String>

PS. Just to add, this is the format of the 3rd Datatable:

Hi @wonderingnoname,

Is the for loop taking too long, so you don’t prefer for each?


I am just wondering if there is a counterpart for this syntax:

dtData.AsEnumerable.ToDictionary(Of String, String)(Function (r) r(“Column1”).toString, Function (r) r(“Column2”).toString)

but rows as index

Hi @wonderingnoname ,

Do you want to Convert the 3rd Datatable to a Dictionary ?

If so, What Column is to be the Key and what columns are to be the values according to you ?

For this one,


The key should be name, status, quantity and the value are the next row

we would recommend to check the different options on how we can represent the datatable / datarow as a string. To mention a few:

  • CSV string
  • JSON serialized string (has some overhead compared to CSV)

Once you have decided on the prefered representation, we can adopt a LINQ for it

Hi ppr,

it would be csv string

Hey @wonderingnoname

Just pass your datatable into an Output Data Table activity.


There is no such thing as Datatable(of string, string)

And you can’t convert a datatable to a string.

If you want to copy the third datatable out of the dictionary to its own datatable variable…

Assign newDt = myDict(“3”)

This means your dictionary can only hold one item. That’s ok if the 3rd datatable only has one row. Will the 3rd datatable always have only one row?

What is your reason for converting it to a dictionary? What are you trying to do that you can’t do with the 3rd datatable itself?