Using Assign between Datatables

What happens if you have an assign statement


Table B is empty not defined just declared. Does it take on datatypes of A?

Table B has been built using a Build Table but it is empty. Will it convert the values? Or does it take on datatypes based on what is sees as a number?

Are there any best practices for assigning structured data types?

Hi @AlienV ,

The best way for assigning structured data types depends on what you what to achieve. Can you give us more details?

For finding out what happens with the scenario 1 and scenario 2 the simplest thing is making a simple test flow! Let us know the outcome :slight_smile:

An example:



Best Regards,

1 Like

Table B will simply become table A object, wiping fully table B column mapping (including format).
If Table B is nothing, then Table A will be nothing too.

Note also that both Table A & B will still refer to the same object (they are actually both pointing to the same object in memory). So if you do change in table A, it should be reflected on table B too.

You want to clear a table (having it with no rows) keeping the formating, You could use TableB = TableA.Clone().


1 Like

Thanks Susana/Florent

Are you saying once I do a

then follow with an Add Row activity to TableA, then TableB will have the same row count even though I have not done another assign statement?

What if Table B is emtpy and I want it to have Table A data but be an independent entity? Do I use a populated TableA with the Clone method?

I was trying to think of the easiest way to convert certain table columns from string to integer by using an assign. I’ve built a datatable and force the contents of web extraction to specific datatypes by assigning to my built table vs a generic blank one. I wanted to do similar but with existing tables.

1 Like


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)



Thank you so much. I will look through this. I will definitely try to use the

EmptyBuildTableNeededDatatypes = ExistingTableWrongDatatype

as a starting point. I am not familiar with .Net other than bare bones primitive types and accessing row/column data from doing the Academy. I think I will have to invest some time (I have lots of that laying around :smirk:) in understanding these datatype conversions and assigning of variables especially as it relates to Datatable and Arrays. If you know any good sites with good VB examples for newbies I’d appreciate it.

Popular tutorials on the web, Googling your problems adding the Keywoard VB.Net and clicking on stack overflow links:slight_smile: and of course (in the first place) reading the Forum!

my previous example assume you had value on the table, that what is preventing you to change the datatype. If it has no rows (like after clone) you can use the example bellow to change type.

One valid approach and maybe better than the previous one is to loop trough initial table with wrong type and rows to cloned one, with DataColumn type changed using the ArrayRow parameter as bellow.

Add Datarow {row(0),row(1).toString}

Link bellow can help you understanding, if not I can build you another example tomorrow (it’s late!)


Thanks again. I’ve used ItemArray to add to a datatable before. I posted earlier today asking about using the DataRow array property to as there seems to be no example/documentation to be found and I couldn’t figure it out.

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