Server Error in '/' Application.

Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

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.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

Source Error:


Line 129:                Byte[] bytes;
Line 130:                if(Request.QueryString["PType"]=="PDF")
Line 131:                bytes = (Byte[])dt.Rows[0]["PhotometryPDF"];
Line 132:                else
Line 133:                    bytes = (Byte[])dt.Rows[0]["PhotometryIES"];

Source File: c:\Website\KliteWebsite2021\AttachmentPhotometryView.aspx.cs    Line: 131

Stack Trace:


[InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.]
   AttachmentPhotometryView.Page_Load(Object sender, EventArgs e) in c:\Website\KliteWebsite2021\AttachmentPhotometryView.aspx.cs:131
   System.Web.UI.Control.OnLoad(EventArgs e) +108
   System.Web.UI.Control.LoadRecursive() +90
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533


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