Using Assign between Datatables

Correct

If you expect this different entity to have the same columns (including type), clone is a good approach yes.
It is also fine to have a second “Build data table” in that case, especially if you want types to change.

AFAIK, you cannot change an existing column type, however you can remove it and add a new one with some (relatively complex, depending on how familiar with .Net you are).

I will break it down for you.

  • Step 1 ==> Convert your column to an array (in my case i am doing Integer > String, you will have to slightly change the expression)

Column2Values = dt.AsEnumerable.Select(Function(r) r(1).ToString).ToArray
in your case you will use
dt.AsEnumerable.Select(Function(r) Cint(r(1))).ToArray

  • Step 2 ==> Remove your column and add a new one, of your type.
    If you need to replace it at a specific position, you can use the approach bellow based on SetOrdinal
  • Step 3 ==> Make a “while” loop with counter that increments the counter at the end of its body


The value expression is:

dt.Rows(index)("Column2String") = column2Values(index)

Basically, you target the row from the datable at the index of the counter, from this row your target the new Column name and you set it’s value with the object with the string at the (string, in my case) at the index of the counter.

Hope this somewhat makes sense :slight_smile:

I’m also attaching you xaml example.

God, been a while i did not write a Clayton post :smiley:

Sequence1.xaml (11.0 KB)

Cheers

2 Likes