Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Find value in Datatable loop

Posted on 2009-05-20
4
Medium Priority
?
650 Views
Last Modified: 2012-05-07
Im trying to find certain text within column 2 of my datatable. Below is what I have so far but its not finding the values even though they exist. Can anyone help me?
For Each DataRow In AS400DS.Rows
            If AS400DS.Columns(2).ToString = "AB" Then
                Absentee.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "VA" Then
                Vacation.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "OT" Then
                OT.DataField = "Hours"
            ElseIf AS400DS.Columns(2).ToString = "WH" Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(AS400DS.Columns(2))
        Next

Open in new window

0
Comment
Question by:ITHelper80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24433499

For Each oRow As DataRow In AS400DS.Rows
            If oRow (2).ToString = "AB" Then
                Absentee.DataField = "Hours"
            ElseIf oRow (2).ToString = "VA" Then
                Vacation.DataField = "Hours"
            ElseIf oRow (2).ToString = "OT" Then
                OT.DataField = "Hours"
            ElseIf oRow (2).ToString = "WH" Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(oRow(2).ToString)
        Next
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24433519
hi,

try this:
For Each DataRow In AS400DS.Rows
            If LCase(AS400DS.Columns(2).ToString) = LCase("AB") Then
                Absentee.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("VA") Then
                Vacation.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("OT") Then
                OT.DataField = "Hours"
            ElseIf LCase(AS400DS.Columns(2).ToString) = LCase("WH") Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(AS400DS.Columns(2))
        Next

Open in new window

0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24433527
For Each myRow As DataRow In AS400DS.Rows
                    If myRow .Item(2).ToString = "AB" Then
                Absentee.DataField = "Hours"
Next
0
 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 2000 total points
ID: 24433539
crud, sorry, my bad, try this instead:
dim dr as DataRow
 
For Each dr In AS400DS.Rows
            If LCase(dr.Columns(2).ToString) = LCase("AB") Then
                Absentee.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("VA") Then
                Vacation.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("OT") Then
                OT.DataField = "Hours"
            ElseIf LCase(dr.Columns(2).ToString) = LCase("WH") Then
                OTx2.DataField = "Hours"
            End If
            Response.Write(dr.Columns(2))
        Next

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question