|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
protect overflow of sql data type decimal(9,3)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 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; } -- Show quoteHide quoteHope this helps. Dan Guzman SQL Server MVP "Zeng" <Zeng5***@hotmail.com> wrote in message news:uPmNC0aBFHA.1452@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 > >
Other interesting topics
date format in parameter
Data reader already open? Question about SQLDataReader SqlDataReader.GetChar(n) failed because of Specified method unsupp OleDbParameter doesn't update value correctly Question on how I can use ForeignKeyConstraint What is the Best way to fetch the most recent updated row in a database Cant get Stored Procedure connection string right?? Dataset created in Code cannot be used in Crystal Reports designer Confused about MissingSchemaAction.AddWithKey |
|||||||||||||||||||||||