473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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
Nov 16 '05 #1
1 2498
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike | last post by:
I am trying to use the bulk insert command but I am getting the following error: ---Begin Error Msg--- Server: Msg 4867, Level 16, State 1, Line 1 Bulk insert data conversion error (overflow)...
2
by: Eugene | last post by:
Hi, In Query Analyzer: update tblUserProcess set usercode = 1002 Error: Arithmetic overflow error for data type tinyint, value = 1002. The statement has been terminated.
4
by: Simon Devlin | last post by:
Hi folks, I've been bashing my head against this all afternoon and am now totally baffled. Given this (a simple routine to turn a ip address string into an decimal) <snip> Dim Parts(3) as...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
22
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
3
by: jer006 | last post by:
Hi I am writing a select statement that has an arithmetic function inside a case statement that uses logic to decide whether to divide or multiply and when I run the arithmetic statements outside...
1
by: sonata | last post by:
I am trying to compare two fields which are char data typr. BUT the comparision must be arithemetic in nature. so i tried to cast both the data base field and my parameter field to big int...
2
by: jou00jou | last post by:
Hi, I have trouble using sscanf and fgets to check for overflow. I will post the assignment specification so I could help whoever would kindly like to offer his/her help. ...
5
by: raghavendrap | last post by:
$tmp = 0xc0211082; $tmp1 = 0xc0000082; Hello friends, I got doubt when i am converting negative hexadecimal to a decimal number.Please look at mentioned example below. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.