[vb.net] Loop through the rows of a particular DataTable

IDE : VS 2008, Platform : .NET 3.5,

Hi,

Here is my DataTable columns :

ID Note Detail

I want to write sth like this :

//below code block is not the right syntax


For each q in dtDataTable.Column("Detail")

    strDetail = Row of Column Detail

 Next

Can anyone give me a suggestion and show me a code sample please ? Thanks.

This question is related to vb.net datatable

The answer is


Dim row As DataRow
For Each row In dtDataTable.Rows
    Dim strDetail As String
    strDetail = row("Detail")
    Console.WriteLine("Processing Detail {0}", strDetail)
Next row

Here's the best way I found:

    For Each row As DataRow In your_table.Rows
        For Each cell As String In row.ItemArray
            'do what you want!
        Next
    Next

You want to loop on the .Rows, and access the column for the row like q("column")

Just:

        For Each q In dtDataTable.Rows
            strDetail = q("Detail")
        Next

Also make sure to check msdn doc for any class you are using + use intellisense