Server Error in '/' Application.

Cannot perform runtime binding on a null reference

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: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference

Source Error:


Line 16: 
Line 17:     var product = db.QuerySingle("SELECT * FROM Products WHERE ProdCode = @0", productcode);
Line 18:     var categoryname = db.QueryValue("SELECT Title FROM Category WHERE ID =@0", product.category);
Line 19:     var subcatof = "";
Line 20:     var mightlike = db.Query("SELECT TOP 4 Title, Sale, ProdCode, Image1 FROM Products WHERE Live ='Yes' AND Category =@0 AND ID <> @1 ORDER BY NEWID()", product.category, product.id);

Source File: d:\Websites\BatemanOgden\www\Product.cshtml    Line: 18

Stack Trace:


[RuntimeBinderException: Cannot perform runtime binding on a null reference]
   CallSite.Target(Closure , CallSite , Object ) +148
   System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +241
   CallSite.Target(Closure , CallSite , Object ) +264
   ASP._Page_Product_cshtml.Execute() in d:\Websites\BatemanOgden\www\Product.cshtml:18
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +99
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +182
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.4076.0