Error : Conversion from type 'DBNull' to type 'Boolean' is not valid


https://forum.kartris.com/Topic1371.aspx
Print Topic | Close Window

By Neil - Fri 30 Sep 2011
Hi, we seem to be getting the following error frequently. Any ideas?

-----------------------------------------------------------------------------
>>     URL:http://www.mtmc.co.uk/Product.aspx?ProductID=58108&CategoryID=12732401&strParent=73,12732400&L=1
>>     Page:
-----------------------------------------------------------------------------
>>     30/09/2011 15:42:01
>>     180.76.5.165
>>     DESCRIPTION:
System.InvalidCastException: Conversion from type 'DBNull' to type 'Boolean' is not valid.
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(Object Value)
   at BasketBLL.GetCouponDiscount(String strCouponCode, String& strCouponError, String& strCouponType, Double& numCouponValue)
   at BasketBLL.CalculateCoupon(String strCouponCode, String& strCouponError, Boolean blnZeroTotalTaxRate)
   at Templates_BasketView.LoadBasket()
   at Templates_BasketView.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

==================================================
By saturation - Fri 30 Sep 2011
Are you able to replicate the error by clicking on the same thing?   If so, what is it you are clicking on that is generating the error?
By Paul - Fri 30 Sep 2011
I clicked the link and the page didn't appear to error for me. The trace includes some info relating to coupons - do you have any coupons live? Is it possible to set up a reusable test coupon with minimal value to test with?
By Neil - Sat 1 Oct 2011
It is odd, when it errors, every page load seems to throw it until I recycle the application pool (to be honest I have never left it long enough to see if it cures itself). We have never used coupons at all, but will try and see if I can reproduce. I wonder if a db field type is incorrect?
By Neil - Sat 1 Oct 2011
Just checked and we did have an old live 'test' coupon that has expired in 2010. Have deleted that. Will see if it happens again...