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().
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.
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
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.
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 ) 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.
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.