nad nad - 6 months ago 98
ASP.NET (C#) Question

Input string was not in a correct format. Expected type in Decimal type

I am not inserting any value in

column and updating it.

But it is giving me error as

Input string was not in a correct format.Couldn't store <> in VOUCHER_NO Column. Expected type is Decimal.

Below is my code

drpayinfo[0]["VOUCHER_NO"] = e.Record["VOUCHER_NO"];


I am using Oracle DB and its datatype is


Seems your e.Record["VOUCHER_NO"] have some unwanted content which is not convertible to decimal. Try this way checking before assignment or conversion

if(e.Record["VOUCHER_NO"] != "")
  drpayinfo[0]["VOUCHER_NO"] = Convert.ToDecimal(e.Record["VOUCHER_NO"]);

But more safer way to detect and ignore bad content is

decimal result;

if (Decimal.TryParse(e.Record["VOUCHER_NO"], out result))
    drpayinfo[0]["VOUCHER_NO"] = result;
    // do stuff if failed to parese