Dim ResourceAdapter As New ResourcesTableAdapters.ResourcesTableAdapter
Dim dF As Data.DataTable = ResourceAdapter.GetDataByResourceID(sID)
Dim RecResource As Resources.ResourcesRow
strBody = "The following link has been reported as broken. "
strBody = strBody & "Please verify before deleting." & Chr(10)
strBody = strBody & "Category: " & RecResource.Category & Chr(10)
strBody = strBody & "Title: " & RecResource.Title & Chr(10)
strBody = strBody & "URL: " & RecResource.URL & Chr(10)
where the GetDataByResourceID(sID) method returns a single row. I get the following error on the core line in bold:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 124: strBody = "The following link has been reported as broken. "
Line 125: strBody = strBody & "Please verify before deleting." & Chr(10)
Line 126: strBody = strBody & "Category: " & RecResource.Category & Chr(10)
Line 127: strBody = strBody & "Title: " & RecResource.Title & Chr(10)
Line 128: strBody = strBody & "URL: " & RecResource.URL & Chr(10)
What am I doing wrong?
Diane
Resources.ResourcesRow is nothing (null).
That is why you are getting the error.
You never assign a value to RecResources that is why you are getting the error. Try something like this
Dim dF As Data.DataTable = ResourceAdapter.GetDataByResourceID(sID)
Dim RecResource As Resources.ResourcesRow = dF.Rows(0)|||
That makes sense, thank you. That fixed it.
Diane
sql
No comments:
Post a Comment