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 131:                bytes = (Byte[])dt.Rows[0]["PhotometryPDF"];
Line 132:                else
Line 133:                    bytes = (Byte[])dt.Rows[0]["PhotometryIES"];
Line 134:                Response.Clear();
Line 135:                Response.Buffer = true;

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

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:133
   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