I need help with an error I'm getting;
"Object reference not set to an instance of an object." The error occurs at the line :
The items in lstStudents is text. StudentID is an autonumber.
What I'm trying to do is populate a the database with all the studentID's of the names in the list box. (i.e. every name in the list box has a corresponding studentID)
Your help would be really appreciated.
Thanks
"Object reference not set to an instance of an object." The error occurs at the line :
Code:
Dim intselA As Integer = CInt(lstStudents.SelectedItem.ToString)
What I'm trying to do is populate a the database with all the studentID's of the names in the list box. (i.e. every name in the list box has a corresponding studentID)
Your help would be really appreciated.
Thanks
Code:
Dim intselA As Integer = CInt(lstStudents.SelectedItem.ToString)
Dim BRow As DataRow = objDataSet.Tables("tblStudent").Rows.Find(intselA)
If BRow IsNot Nothing Then
'use the data relationship to find all matching student rows
Dim studentRows() As DataRow = BRow.GetChildRows("tblStudent")
If studentRows.Length > 0 Then
For Each student As DataRow In studentRows
Dim strID As String = student("StudentID")
'add this item
objCurrentRow1.Item("StudentID") = strID
Next
End If
End If
Comment