0
檢查後我有以下代碼:的NullReferenceException即使IsDBNull以便
Dim getProspect = (From p In dbContext.IRF_Prospects _
Where p.url = prospect_url _
Select p).FirstOrDefault
' If they have a record...
If Not IsDBNull(getProspect) Then
If IsDBNull(getProspect.user_id) Then
' Prepopulate the form with their information.
txtFirst.Text = getProspect.first_name
Else
' Redirect them to login.
Response.Redirect("login.aspx")
End If
當我執行它,它拋出一個對象引用不設置爲一個對象錯誤的實例上getProspect.user_id
。它爲什麼這樣做?不應該使用IsDBNull
首先驗證它是否存在這一事實?