How to select a column using column position

Hi have a data table which has repeated column names.I want to select few columns from that.
How to select the column name using its position and is der any way to read that column name to confirm whether i have selected the right column

Hi @subashini,

You can use Datatable column index, dattablename.Column(0) → this will get you the first column of the data table. And then there is a ColumnName property you can use it to verify the column which you have pulled.

Hi @subashini,
Yes sarathi125 is right. By this example you can able to know very well

File :DataTable.zip (2.0 KB)

Regards
Balamurugan

Thanks:grinning:

Hi first i have one doubt if column names are same we can not read the data or generate a data table

columns

I have to select the second column with the name “City” . so for this i need to select column using its position

If you are using the DataRow
to get the City Column value you have to use like this row(“City”).ToString or row(3).ToString

To get the Column Info DtExcel.Columns(“City”) or DtExcel.Columns(3)

Regards
Balamurugan