mortizs
(Mortizs)
1
Hello, my problem is this:
I have a DataTable, and I need to get all the unique values from one column of this DataTable, in one Array.
In other words, I need a VB.net expression in which the input is the DataTable and its column and returns an array with the unique values.
The expression I tried was:
[DT_name].DefaultView.ToTable(true, “ColumnName”)
But the output was a list type.
Thanks for the help!
ppr
(Peter Preuss)
2
lets assume we want to get a string array
DT_name.AsEnumerable.Select(Function (x) x(YourColNameOrIndex).toString).toArray
for unique values we add distinct()
DT_name.AsEnumerable.Select(Function (x) x(YourColNameOrIndex).toString).Distinct().toArray
3 Likes
mortizs
(Mortizs)
3
Thanks Man! That’s exactly what I needed. It worked!
system
(system)
Closed
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.