I have tried so many things to make this seemingly simple task work
How do I store the column names of a data table to an array? The array is to be used for the drop-down input dialog options. I can get the column values to an array, the row values to an array, but the column names I just can’t seem to get.
I get several compile errors using your code:
Option strict on disallows late binding
Operator + is not defined for types “System.Data.Datacolumn” and “string”
The loop way might work, and that is the most important thing, but I was hoping for a more sexy solution like the code one below that returns column values as an array. The best solution for me would to have a similar code that returns an array with the column names not the column values. The code itself will work if I store the column names as values in a column in a data table and then retrieves the column names with the code below, but that do not seem efficient to me.
(From row in DT.DefaultView.ToTable(true, “ColumnName”).AsEnumerable() Select Convert.Tostring(row(“ColumnName”))).ToArray()