Assign name of column to string

Hi,

I assign name of columns in my data table to string. I use:

strColumn = dtDataTable.Columns(intCounter+1).ToString

I my data table I have:
row1 - column name
row2 - description of column

A would like to assign date from row2 (as description). How to edit my primary assign: strColumn = dtDataTable.Columns(intCounter+1).ToString

Any ideas?

If you want the name of the columns then use: strColumn = dtDataTable.Columns(intCounter+1).ColumnName

Ok, but I still get name from row1, not row2. It is problem.

Generally we get the same result if we use
strColumn = dtDataTable.Columns(intCounter+1).ColumnName
or
strColumn = dtDataTable.Columns(intCounter+1).ToString

Yes, column names will be always the same inside the same datatable, they are not per row :slight_smile: If you want the values of columns (and not the name), then you have to get like this: strColumn = dtDataTable.Rows(intCounter+1).ToString

Please see example in xls, what I would to get.
data table description.xlsx (16.4 KB)

Please see example in xls, what I would to get.
data table description.xlsx (16.4 KB)

Datatable column has no property like “Description of column”
It only has column name and data (in rows) - like you can see in BuildDataTable activity

image

I suspect you are mixing up data in datatable rows with properties of datatable object (e.g. name of column)

Cheers

Ok. Then is it possible to delate first “row” as name of columns, to receive description of columns?

Eg.
from
NameColumn1 NameColumn2 NameColumn3
DescriptionColumn1 DescriptionColumn2 DescriptionColumn3

receive only
DescriptionColumn1 DescriptionColumn2 DescriptionColumn3
?

Sry, but if you use a DT, the names of the Columns will not change only the rows will change.

Why not assing
strColumn = “Column1”

And if your row is 0 you now its collumn 1

You can assing strColumn+row(0).toString or else

Why complicate when you can make it simple…

1 Like

Thank you, it helps my.

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