How to select a column using column position

datatable
excel
selector
sql

#1

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


#2

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.


#3

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

File :DataTable.zip (2.0 KB)

Regards
Balamurugan


#4

Thanks:grinning:


#5

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


#6

columns

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


#7

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