473,803 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Numeric overflow . No errors. Insert the wrong number

Hi,

I have a field: usercode [tinyint]

In Query Analyzer:
UPDATE tblUserProcess
SET usercode = 1002

Result: Error "Arithmetic overflow error for data type tinyint, value = 1002.
The statement has been terminated."
In VBA/Access ( linked to SQL Server ):

intOptions = 512
pstrQuerySQL = "UPDATE ..."
CurrentDb.Execu te pstrQuerySQL, intOptions

Result: no errors, insert value 223 (???)

Why?

Thanks, Eugene
Jul 23 '05 #1
6 4124
TINYINT max value is 255. The error msg said it can't insert value
1002 -- I don't understand what the 223 is about.

Jul 23 '05 #2
The max value for a tinyint is 255. as your value is more then that,
SQL Server gives you this message.

--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com

Jul 23 '05 #3
Eugene (yg********@hot mail.com) writes:
I have a field: usercode [tinyint]

In Query Analyzer:
UPDATE tblUserProcess
SET usercode = 1002

Result: Error "Arithmetic overflow error for data type tinyint, value =
1002.
The statement has been terminated."

In VBA/Access ( linked to SQL Server ):

intOptions = 512
pstrQuerySQL = "UPDATE ..."
CurrentDb.Execu te pstrQuerySQL, intOptions

Result: no errors, insert value 223 (???)

Why?


If the string you pass from the VBA app really is
"UPDATE tblUserProcess SET usercode = 1002", then there is something
really fishy going on.

I can see a couple of possibilities:
1) You have poor error handling in the VBA code, so you fail to catch
the error. The column already had the value 223 prior to the UPDATE.
2) The statement is parameterized, and the VBA code loses the upper bits
of 1002. In such case you get 224. Is 223 a typo?

More information would be useful.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

Erland Sommarskog wrote:

I can see a couple of possibilities:
1) You have poor error handling in the VBA code, so you fail to catch
the error. The column already had the value 223 prior to the UPDATE. 2) The statement is parameterized, and the VBA code loses the upper bits of 1002. In such case you get 224. Is 223 a typo?


How do you get 224?

Is this calculated by translating 1002 into hex giving you 0x3EA,
stripping the 3 as a tiny int is only two bytes leaving 0xEA, then
converting back to dec.

In this case the number would be 234.

Just asking as I have always wanted to know how this works.

--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com

Jul 23 '05 #5
dbmonitor (db************ ***@hotmail.com ) writes:
How do you get 224?

Is this calculated by translating 1002 into hex giving you 0x3EA,
stripping the 3 as a tiny int is only two bytes leaving 0xEA, then
converting back to dec.

In this case the number would be 234.


I used "SELECT 1002 % 256". Hm, now in the light of day the result is indeed
234. Hm...
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #6

Erland Sommarskog wrote:
dbmonitor (db************ ***@hotmail.com ) writes:
How do you get 224?

Is this calculated by translating 1002 into hex giving you 0x3EA,
stripping the 3 as a tiny int is only two bytes leaving 0xEA, then
converting back to dec.

In this case the number would be 234.
I used "SELECT 1002 % 256". Hm, now in the light of day the result is

indeed 234. Hm...
Trust me to take the programmers approach!!! B^D
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
3146
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form (nested), three list views, one tree control with up to 30,000 nodes, maybe 15 comboboxes (half of which have a large recordset as rowsource), 20 or so buttons and around 30 text boxes (not to mention the images, labels, etc and around 1000 lines...
2
8394
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.
6
9234
by: M.A. Oude Kotte | last post by:
Hi All, I hope this is the correct mailing list for this question. But neither postgresql.org nor google could help me out on this subject. I did find one disturbing topic on the mailing list archives (http://archives.postgresql.org/pgsql-admin/2000-05/msg00032.php), but since it was quite old I'm posting my question anyway. I'm writing a generic database layer that should support a fixed number of generic numeric types on a number of...
25
6281
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do something;
20
3722
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If MyVariant = 2 Then MsgBox "MyVariant also equals the value 2" 160 If MyVariant = "" Then HowManyCopies = 1 170 If Not IsNumeric(MyVariant) Then HowManyCopies = 1 MsgBox "OK. HowManyCopies has a value of " & CStr(HowManyCopies) 180 For i =...
0
2424
by: rajmgopal | last post by:
Hello Everyone I am getting the following error when i try to insert a record into Sql Server 2005 from my VB 2005 application. sqlEx = {"Error converting data type numeric to numeric."} I checked for possible overflow exception, but did not encounter any. I have declared the values that i am trying to insert as DECIMAL data types in my VB code.
12
11838
by: Geoff Cox | last post by:
Hello, Some one is getting the "stack overflow" error message when using a Javascript program which I wrote when using Internet Explorer but not when using Mozilla. Any ideas as to how I might find out what is happening? Cheers,
20
5834
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including negative numbers into a separate sequence and ignore the (now empty) args list returned by getopt, but it would seem this is such a common requirement that there would be an option to treat a negative value as an argument. Note that this is only a...
2
686
by: jgscott3 | last post by:
I have a query that simply totals a number of fields from a linked table. If I run it several times, it works fine for a couple of runs and then inexplicably returns a numeric field overflow error message. If I then open it in design view and change the format of any total field (it doesn't seem to matter which one!), it will again run fine a couple of times. Then the error message will occur again. Can anyone please explain this and...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.