Server Error in '/' Application.

Conversion from type 'DBNull' to type 'Integer' 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: Conversion from type 'DBNull' to type 'Integer' is not valid.

Source Error:


Line 701:        Dim myProductDetails As ProductDetails = New ProductDetails
Line 702:
Line 703:        myProductDetails.CategoryID = CInt(parameterCategoryID.Value)
Line 704:        myProductDetails.ModelNumber = CStr(parameterModelNumber.Value).Trim()
Line 705:        myProductDetails.ModelName = CStr(parameterModelName.Value).Trim()

Source File: D:\web\blackswan\www20\App_Code\ProductsDB.vb    Line: 703

Stack Trace:


[InvalidCastException: Conversion from type 'DBNull' to type 'Integer' is not valid.]
   Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value) +1832
   ProductsDB.GetProductDetails(Int32 productID) in D:\web\blackswan\www20\App_Code\ProductsDB.vb:703
   ProductDetailsPage.Page_Load(Object sender, EventArgs e) in D:\web\blackswan\www20\ProductDetails.aspx.vb:49
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428


Version Information: Microsoft .NET Framework Version:2.0.50727.8806; ASP.NET Version:2.0.50727.8762