|
-
Sep 18th, 2013, 01:35 PM
#1
Thread Starter
Fanatic Member
Finding a Row Within a Data Table
I'm trying to find a value a value within a data table based on a record I'm reading from another table.
For example, I have a number called "PCS Visit" in my first table. While looping through the records in that table, I throw the data into a datagridview. One of the values I need is in another table though.
To get the other value, I'm trying to say "go find the row in table 2 where the PCS visit number = the current record's PCS Visit Number". When you find it, bring back the "AdmitBed" associated with the PCS Visit Number in table 2.
My FoundRow = dsNRCPicker row seems to work, I just don't know how to get the value for AdmitBed from the row it found.
Code:
Dim FoundRow() As Data.DataRow
FoundRow = dsNRCPicker.Tables("dtAdmitBed").Select("PCS_Visit = " & DataReader.Item("PCS_Visit"))
anyRow("AdmitBed") = FoundRow :(
-
Sep 18th, 2013, 01:54 PM
#2
Re: Finding a Row Within a Data Table
Try this
Code:
Dim FoundRow() As Data.DataRow
FoundRow = dsNRCPicker.Tables("dtAdmitBed").Select("PCS_Visit = '" & DataReader.Item("PCS_Visit").ToString & "'")
If FoundRow.Length = 1 Then
anyRow("AdmitBed") = FoundRow(0)("AdmitBed")
End If
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Sep 18th, 2013, 02:22 PM
#3
Thread Starter
Fanatic Member
Re: Finding a Row Within a Data Table
It didn't care for the .ToString & "'") business that you added but I removed that, and BINGO.
Thanks - that is a very big help.
-
Sep 18th, 2013, 03:15 PM
#4
Re: Finding a Row Within a Data Table
Option Strict is your friend
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|