I have a class (GuestList) and I want to create a list of guests using iList.
I'm looping through results in my SQL server search and want to add each guest to my list but I get the below error.
What is wrong?
I'm looping through results in my SQL server search and want to add each guest to my list but I get the below error.
What is wrong?
vb.net Code:
Dim GuestList As IList(Of GuestClass) 'Via a SQL SERVER DATAREADER LOOP RESULT Dim FoundGuest As New GuestClass FoundGuest.GuestID = reader(0) FoundGuest.GuestFirstName = reader(2) FoundGuest.GuestLastName = reader(3) GuestList.Add(FoundGuest)
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.GuestSearch.Button2_Click(Object sender, EventArgs e) in C:\Users\PC1\Desktop\Projec1\GuestSearch.vb:line 28