This works:
Dim dt As System.Data.DataTable
Dim r As System.Data.DataRow = dt.Rows.Item(i)
i = r.Item(2)
But, I would like to retirive column value by entering
column name not by index ( r.Item(2)
). The problem is that I don't know column name and I would like somehow to
list all column names of DataTable. How can I do that?
Please help and sorry for incomplete info.
Aidy - 05 Mar 2008 09:24 GMT
r = dt.Rows(i)
i = r("FieldName")
Not too hot on VB.net, you might need;
i = r.Item("FieldName")
> This works:
>
[quoted text clipped - 9 lines]
>
> Please help and sorry for incomplete info.
John Smith - 05 Mar 2008 09:52 GMT
The problem is that I don't know field name. :(
Aidy - 05 Mar 2008 11:16 GMT
> The problem is that I don't know field name. :(
Sorry, didn't read the question. To get all the column names (sorry it's in
c#)
foreach (DataColumn col in dt.Columns)
{
string name = col.ColumnName;
}
John Smith - 05 Mar 2008 11:49 GMT
> foreach (DataColumn col in dt.Columns)
>
[quoted text clipped - 3 lines]
>
> }
Thank you. I will try that.