c# Decimal value is causing and out of range error when using Microsoft.Practices.EnterpriseLibrary

Viewed 25

Here is my problem:

I have a property: Decimal MaxAmount = 9999999999999.00M; This is getting inserted into a database using Microsoft.Practices.EnterpriseLibrary.Data ExecuteReader

When ExecuteReader is called an error is thrown saying there is an out of range error with MaxAmount = 9999999999999.00.

When I look in the database I see that MaxAmount is set as a Data type = numeric with precision = 19 and scale = 2 there is also a Length property on MaxAmount that is set to 9.

When I reduce MaxAmounts value to 9999999M the record passes which conveniently if you add .00 to the end of that is a length of 9.

Everything I am reading seems to say that the Length is related to the bytes and not the number of characters.

Even more strange is that MaxAmount in the database has records with 9999999999999.00 in them.

Does anyone know:

  1. Is the Length Property in SQL determined by the set precision and scale or is it completely separate and if so, how would I alter this property?

  2. Does anyone know why this is an issue and if there is something I can do in c# or with Microsoft.Practices.EnterpriseLibrary.Data to make this passable to the database?

0 Answers
Related