Dim id As Integer
Dim tempIdList As List(Of Integer)
If dr.Read() Then
Do
Dim loc As String
loc = dr("CurrentLocation").ToString()
id = dr("ID")
'tempIdList.Add(dr("ID"))
'tempIdList.Add(id)
If loc = comboFrom.Text Then
isContinue = True
End If
Loop While dr.Read
End If
我试过那些评论过的代码。但我得到Object reference not set to an instance of an object
我尝试添加一个断点,似乎列表没有得到值,仅Nothing
,而id
具有访问数据库中ID的值。
有什么问题?
答案 0 :(得分:2)
tempIdList
可能是Nothing
。您必须先使用New
关键字创建实例:
Dim tempIdList As List(Of Integer) = New List(Of Integer)