VB.NET - How do I retrieve a value from a particular column in a DataTable?

Here's a basic question.  What code do I use to retrieve values from a particular column in the data row?  I want to reference the column by column name not by column index.
Dim dstPadlockRow As DataSet
Dim dr As DataRow
Dim ColumnValue As String
      
.... ' omitted code

For Each dr In dstPadlockRow.Tables(0).Rows
   ColumnValue = dr.    <------------- What do I do here?
   .... ' more omitted code
Next

Open in new window

jdanaAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
For vb.net: dr("YourFieldName")
0
 
DhaestCommented:
0
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
ColumnValue = dr.Item("YourColumnName").ToString
0
 
jdanaAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.