0

I have written a stored procedure which returns one of the value as REAL datatype since it is referring to some old database table.

I want to convert/map this value to a decimal? type in C#. However, I get an error:

Specified cast not valid

when running this code:

item.SludgeCapacity =v.Field<decimal?>("SludgeCapacity");

Does anyone have an optimised solution?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user19041992
  • 133
  • 1
  • 5
  • 18
  • 1
    https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings –  Aug 03 '18 at 17:59

1 Answers1

0

try

item.SludgeCapacity = Convert.ToDecimal(v.Field("SludgeCapacity"));
Aldert
  • 4,209
  • 1
  • 9
  • 23