By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,302 Members | 1,788 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,302 IT Pros & Developers. It's quick & easy.

protect overflow of sql data type decimal(9,3)

P: n/a
Hello,

I have many fields in my SQL database that are of type decimal(9,3). How do
I detect a decimal value (type decimal in C#) will overflow the db column of
sql type decimal (9,3)? Is there a way to figure out the min/max constants
of decimal(9,3) to compare against in C# to make sure the new value is "in
bound"?

Thanks!
-zeng
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you know that the SqlDecimal precision is 9 and the scale is 3, you can
simply do a range validation like the example below.

private bool IsInBound(decimal DecimalValue)
{
if((DecimalValue > 999999.999m) || (DecimalValue < -999999.999m))
return false;
return true;
}
--
Hope this helps.

Dan Guzman
SQL Server MVP

"Zeng" <Ze******@hotmail.com> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
Hello,

I have many fields in my SQL database that are of type decimal(9,3). How
do
I detect a decimal value (type decimal in C#) will overflow the db column
of
sql type decimal (9,3)? Is there a way to figure out the min/max
constants
of decimal(9,3) to compare against in C# to make sure the new value is "in
bound"?

Thanks!
-zeng

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.