Putiing DataTable into an Array

Hi everyone,

i am trying to put information from my DataTable into an array. I am filtering the DataTabel until there is only one Column left. Each Column is a String value. I now want to put each String Value into one index of an array. I just can’t figure out how.
Thanks for the Help!

Use YourColumnString.Split(" ") in an Assign Activity which populates an array variable for each column

Hi @Robin112

Please find below methods.
METHOD 1:

Count = 0
For each row in Datatable
ListValues[Count ] = row(0).tostring
Count = Count + 1
Next

ListValues is of List type.

METHOD 2:

List(of string) = (From row in InputDT.AsEnumerable() Select Convert.Tostring(row(“ColumnName”))).ToList()

Please change column name with your data table column name or use index of the column.

Regards,
Vijay.

2 Likes

I am getting an error which tells me that i cant convert String to char when doing this

but this will give me a List right!? I need an array

Apologies, this is the way to handle the char->string conversion

YourColumnString.Split(" "c)

Hey @Robin112

is your data has fixed size ??
Because arrays will allow you to store some fixed number of elements only. The benefit of List is that you can store any number of values at a time.

That is the reason i gave solution with List.

Can you please be more specific why you need only array ???

Regards,
Vijay.

ViJay, you asked about my preference for an array.
When processing at table from the sqlserver,
I need to know when I am at the last row for my user.
So, on the current row, I need to compare the username on the current row,
to the user name on the next row.
an array would make this possible.
David
p.s. Maybe you have a way to do this comparison?