By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,091 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,091 IT Pros & Developers. It's quick & easy.

REPOST System.Data.DataTable

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

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

P: n/a

"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

P: n/a
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.