468,293 Members | 1,853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,293 developers. It's quick & easy.

REPOST System.Data.DataTable


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.
Mar 5 '08 #1
4 1102
r = dt.Rows(i)
i = r("FieldName")

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

i = r.Item("FieldName")

"John Smith" <jo********@microsoft.comwrote in message
news:2i*******************@news.siol.net...
>
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.

Mar 5 '08 #2

The problem is that I don't know field name. :(
Mar 5 '08 #3

"John Smith" <jo********@microsoft.comwrote in message
news:O3*******************@news.siol.net...
>
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;

}
Mar 5 '08 #4
foreach (DataColumn col in dt.Columns)
>
{

string name = col.ColumnName;

}
Thank you. I will try that.
Mar 5 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Programatix | last post: by
reply views Thread by Doug | last post: by
7 posts views Thread by Mythran | last post: by
4 posts views Thread by Dariusz Tomon | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.