|
-
Dec 2nd, 2011, 04:04 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Iterating through Datatable Columns
Hi,
I am wondering if it is possible to iterate using columns of datatable.
thanks
I have tried something like this:
Code:
Dim myCol As New DataColumn
Dim myRow As DataRow = Nothing
Dim myCell As New DataGridCell
For Each myCol In myDt1.Columns
For Each myCell In myCol
MsgBox(myCell.ToString)
Next
Next
-
Dec 2nd, 2011, 04:20 AM
#2
Re: Iterating through Datatable Columns
A DataTable is supposed to be basically an in-memory representation of a database table. Just like for a database table, in a DataTable the data is stored in the rows, not the column. The columns just describe the data, e.g. data type, size, nullability, etc. You need to loop through the rows of the table then, for each row, loop through the columns to get the data from the field from that column in the row. When indexing a DataRow, you can use an ordinal index, i.e. number, or you can use a column name or you can use the DataColumn itself.
-
Dec 13th, 2011, 11:57 PM
#3
Thread Starter
Hyperactive Member
Re: Iterating through Datatable Columns
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|