Reputation:
Following code gives values in the 8th column. Following code is okay.
Dim myDataTable As System.Data.DataTable = New System.Data.DataTable
For Each row As System.Data.DataRow In myDataTable.Rows
MessageBox.Show(row.Item(7).ToString)
Next
Following code doesn't give values in the 8th row. Following code is not okay.
Dim myDataTable As System.Data.DataTable = New System.Data.DataTable
For Each col As System.Data.DataColumn In myDataTable.Columns
MessageBox.Show(col.Item(7).ToString)
Next
Any suggestion?
Upvotes: 1
Views: 2111
Reputation: 7142
Dim dt As New DataTable()
Dim eightRow = dt.Rows(7)
For x = 0 To dt.Columns.Count - 1
MessageBox.Show(eightRow(x).ToString())
Next
Upvotes: 0
Reputation: 19641
The DataColumn
class doesn't have an Item
property. If you want to iterate through the items of the 8th row, you can do so using the ItemArray
property of the DataRow:
For Each item In myDataTable.Rows(7).ItemArray
MessageBox.Show(item.ToString)
Next
Upvotes: 1