• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

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

0
jdana
Asked:
jdana
  • 2
2 Solutions
 
DhaestCommented:
0
 
DhaestCommented:
For vb.net: dr("YourFieldName")
0
 
Éric MoreauSenior .Net ConsultantCommented:
ColumnValue = dr.Item("YourColumnName").ToString
0
 
jdanaAuthor Commented:
Thanks!
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now