2

I am little bit stuck here .. I have a datatable as _

Dim dtPupil As New DataTable

dtPupil.Columns.Add("PupilId", GetType(Integer))
dtPupil.Columns.Add("Forename", GetType(String))
dtPupil.Columns.Add("Surname", GetType(String))

I made a select (assuming names combination will be unique)

Dim strQuery As String = "Forename ='" & forename & "' and Surname = '" & surname & "'"
Dim dr As DataRow()
dr = dTablePupil.Select(strQuery)

I wanna have PupilId as an Integer of the row that match, so

Dim PupilID As Integer = ?????????? 

What do I need to write here? There will only be 1 row returned.

madth3
  • 7,275
  • 12
  • 50
  • 74
Laurence
  • 7,633
  • 21
  • 78
  • 129

1 Answers1

3

Firstly check the length of DataRow array,

IF dr.Length<>0 Then
  PupilID= CType(dr(0)("PupilId"),Integer)
End If
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
  • it's great .. i will accept as an answer .. i am told to wait 3 minutes .. thanks so much .. it works – Laurence Feb 23 '12 at 12:01