views:

13

answers:

0

I've encountered the following InvalidOperationException when trying to insert a value of 91 to Numeric(19,4) row into an MS SQL table.

{"The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column."}

Inner Exception: {"Parameter value '91.0000' is out of range."}

I've discovered that the problem is that I add some SqlDecimals before storing this value in a database. If I explicitly change precision of the SqlDecimal to match the schema the problem goes away. Is this the most effective way to address this issue? I would rather prefer not to introduce additional dependendency of the schema in my C# code.