locked
ClubStarterKit.Web.News.GetImages Error RRS feed

  • Question

  • User403614158 posted

    Hi Everyone,

    I can't seem to figure out a fix for this, I keep getting the following error in my log.  Can someone help me fix this?  Not sure what it means...

    ERROR:

    System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Nullable object must have a value.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Nullable`1.op_Explicit(Nullable`1 value)
       at ClubStarterKit.Web.News.GetImages(Int32 NewsID) in C:\HostingSpaces\somesite.com\wwwroot\App_Code\BLL\News.vb:line 93
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
       at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
       at System.Web.UI.WebControls.BaseDataList.GetData()
       at System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource)
       at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
       at System.Web.UI.WebControls.BaseDataList.DataBind()
       at System.Web.UI.WebControls.BaseDataList.EnsureDataBound()
       at System.Web.UI.WebControls.BaseDataList.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       --- End of inner exception stack trace ---
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at ASP.news_print_aspx.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    

    Thanks!!
    Tuesday, December 6, 2011 11:13 PM

All replies

  • User-1623236949 posted

    One thing I've noticed that some of the pages such as add events, add news don't have the form validation in place, which let you submit a page with empty/null values. This breaks the page.

    Look at the corresponding table and see if you have a null values for the specific record. You can either delete the entire record or edit the cell.

    Hope that helps.

    Eric

    Thursday, December 29, 2011 2:20 PM
  • User403614158 posted

    Hi EJM,

    Thanks for teh feedback.  I checked the database and the table "Announcements" has two columns "photo" & "albumid" and set to INT.  The values for both columns (if there is no image associated with the news article) is "0" not NULL.  So it looks like my table is set up correctly.

    As the error states, the exception thrown is on BLL/News.vb (line 93). here is the entire code for that line (line 93 is bold)

     Public Shared Function GetImages(ByVal NewsID As Integer) As IDataReader
                Dim Article As New Announcements(NewsID)
                Dim albumid As Integer = Article.Albumid

                Dim qry As New Query(Tables.Images)
                qry.AddWhere(Images.Columns.Album, albumid)

                Dim rdr As IDataReader = qry.ExecuteReader()
                Return rdr
                rdr.Close()
            End Function

    If albumId is "0" would the above code throw an exception? 

    Thanks for any feedback.  My email is inudated with messages about this error and I am trying to relieve it and I don;t know how.

    I am not much of a coder so your help is very appreciated.

    Thursday, December 29, 2011 3:36 PM
  • User-1623236949 posted

    No sure what would cause it then. See if you can insert an image id into the database field replacing the zero. Can you delete the record from DB and see if the error shows up with ohter records? Before deleting, you may want to copy the data to a notepad so you can later recreate it.

    Take a look at the NewsID you're passing in Dim Article As New Announcements(NewsID) to make sure if it has an actual value.

    That's all can recomend - not that this is hepfull, but I'm on 4th version of the database. Each time someting like that happened where I couldn't figure things, I just started over. Perhaps this will give you some ideas.

    Good Luck.

    Eric

    Thursday, December 29, 2011 3:52 PM