473,406 Members | 2,343 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.

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.Execute pstrQuerySQL, intOptions

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

Why?

Thanks, Eugene
Jul 23 '05 #1
6 4100
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********@hotmail.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.Execute 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****@sommarskog.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****@sommarskog.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****@sommarskog.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
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...
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.
6
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...
25
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...
20
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...
0
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...
12
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...
20
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...
2
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
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...

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.