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 49: 
Line 50:                     'declare your select query parameters
Line 51:                     cmd.Parameters.Add("@adid", SqlDbType.Int).Value = Convert.ToInt32(keyValues(i)(0))
Line 52: 
Line 53:                     'open the connection and send the query

Source File: C:\HostingSpaces\linky\linkytools.com\wwwroot\ads_paid.ascx.vb    Line: 51

Stack Trace:


[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider) +55
   System.Convert.ToInt32(Object value) +31
   ads_paid.ASPxGridView1_DataBound(Object sender, EventArgs e) in C:\HostingSpaces\linky\linkytools.com\wwwroot\ads_paid.ascx.vb:51
   DevExpress.Web.ASPxDataWebControlBase.OnDataBound(EventArgs e) +81
   DevExpress.Web.ASPxGridBase.OnDataBound(EventArgs e) +33
   DevExpress.Web.Internal.DataHelper.OnDataSourceViewSelectCallback(IEnumerable data) +149
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +34
   DevExpress.Web.Internal.DataHelper.PerformSelect() +203
   DevExpress.Web.Internal.GridDataHelper.PerformSelect() +285
   DevExpress.Web.Internal.DataContainer.PerformSelect() +136
   DevExpress.Web.ASPxDataWebControlBase.DataBindCore() +13
   DevExpress.Web.ASPxDataWebControlBase.DataBindInternal() +110
   DevExpress.Web.ASPxWebControl.DataBind() +37
   DevExpress.Web.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +59
   DevExpress.Web.Internal.DataContainer.EnsureDataBound() +142
   DevExpress.Web.ASPxDataWebControlBase.OnPreRender(EventArgs e) +22
   System.Web.UI.Control.PreRenderRecursiveInternal() +90
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Control.PreRenderRecursiveInternal() +163
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +906


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