Server Error in '/' Application.

Specified cast is not valid.

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: Specified cast is not valid.

Source Error:


Line 253:                for (int i = 0; i < dt.Rows.Count; i++)
Line 254:                {
Line 255:                    books[i] = new Book(
Line 256:                                        dt.Rows[i]["ShortDanacode"] + "",
Line 257:                                        dt.Rows[i]["Name"] != DBNull.Value ? (string)dt.Rows[i]["Name"] : null,

Source File: c:\inetpub\sit\bookme-sifriyot\App_Code\BL\Book.cs    Line: 255

Stack Trace:


[InvalidCastException: Specified cast is not valid.]
   MoishMedia.NewBookme.Library.Book.GetBooksByCmd(DALtier dal) in c:\inetpub\sit\bookme-sifriyot\App_Code\BL\Book.cs:255
   MoishMedia.NewBookme.Library.Product.GetProductCodeByCmd(DALtier dal, Book[]& books) in c:\inetpub\sit\bookme-sifriyot\App_Code\BL\Product.cs:20
   MoishMedia.NewBookme.Library.Product.GetProductCodeByCmd(DALtier dal) in c:\inetpub\sit\bookme-sifriyot\App_Code\BL\Product.cs:27
   MoishMedia.NewBookme.Library._SubCategory.Page_Load(Object sender, EventArgs e) in c:\inetpub\sit\bookme-sifriyot\SubCategory.aspx.cs:70
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


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