2016-03-02 63 views
0

我得到一個NullReferenceException錯誤,同時保存記錄與下面的語句:的NullReferenceException發生

Dim sel As String = "select COUNT(*) from Master_URLEntry where Projectname='" &0 G_Current_Project & "' and ListCode like '%" & sCode & "%' "] 
If blnAdd = False Then 
    sel += "and Recordid not in ('" & _dtMasterRow.Item("RecordID") & "')" 
End If 
+3

可能重複[什麼是NullReferenceException,我該如何解決它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-doi-i-fix-它) – Jay

+0

並提防SQL注入 – Fredou

回答

0
NullReferenceException 

意味着你正在得到越來越,你認爲你應該值的一個簡單的詞。在此之前放置一個斷點,然後使用F11進行操作。當一條線將黃色鼠標懸停在每個變量上,並檢查它是否有價值。

找到哪一個導致異常,並返回單詞來查看最新的錯誤,因爲上述語句中沒有任何錯誤。

我的教育猜測是這個_dtMasterRow.Item("RecordID")由於某種原因沒有價值。

相關問題