problem in cast value from money to decimal
-
this is my code public decimal OrderTotal; SqlParameter parameterOrderTotal = new SqlParameter("@OrderTotal", qlDbType.Money); parameterOrderTotal.Direction = ParameterDirection.Output; myCommand.SelectCommand.Parameters.Add(parameterOrderTotal); retreive this value by myOrderDetails.OrderTotal = (decimal)parameterOrderTotal.Value; some times ite work fine but sometime its show errror Specified cast is not valid. Tahnx
-
this is my code public decimal OrderTotal; SqlParameter parameterOrderTotal = new SqlParameter("@OrderTotal", qlDbType.Money); parameterOrderTotal.Direction = ParameterDirection.Output; myCommand.SelectCommand.Parameters.Add(parameterOrderTotal); retreive this value by myOrderDetails.OrderTotal = (decimal)parameterOrderTotal.Value; some times ite work fine but sometime its show errror Specified cast is not valid. Tahnx
You need to check for a null value (or DBNull.Value) before casting it.
*Developer Day Scotland - Free community conference Delegate Registration Open