REPOST System.Data.DataTable

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

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.
 
r = dt.Rows(i)
i = r("FieldName")

Not too hot on VB.net, you might need;

i = r.Item("FieldName")
 
John Smith said:
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;

}
 
Back
Top