Server Error in '/' Application.

Object cannot be cast from DBNull to other types.

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: Object cannot be cast from DBNull to other types.

Source Error:


Line 2006:            myProductDetails.Name = Convert.ToString(parameterName.Value);
Line 2007:
Line 2008:            myProductDetails.Classification1ID = Convert.ToInt32(parameterClassification1ID.Value);
Line 2009:            myProductDetails.Classification1Name = Convert.ToString(parameterClassification1Name.Value);
Line 2010:

Source File: e:\Sitios\todoaplazo.com\httpdocs\App_Code\ProductsDB.cs    Line: 2008

Stack Trace:


[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider) +56
   System.Convert.ToInt32(Object value) +28
   ProductsDB.GetProductDetails(Int32 productID, Int32 SiteID) in e:\Sitios\todoaplazo.com\httpdocs\App_Code\ProductsDB.cs:2008

[Exception: Error en Capa de datos: Object cannot be cast from DBNull to other types.]
   ProductsDB.GetProductDetails(Int32 productID, Int32 SiteID) in e:\Sitios\todoaplazo.com\httpdocs\App_Code\ProductsDB.cs:2042
   AddToCart.Page_Load(Object sender, EventArgs e) in e:\Sitios\todoaplazo.com\httpdocs\AddToCart.aspx.cs:26
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.9174; ASP.NET Version:2.0.50727.9175