Solved

Value was either too large or too small for an Int32.

Posted on 2013-06-18
3
3,888 Views
Last Modified: 2013-06-25
I am trying to convert a string variable to a number but keep getting this error message.  Any ideas why this keeps occurring.  Any help is greatly appreciated.

Sample Data: 7417355331


            string practiceTaxId;
            decimal mpracticeTaxId;
            practiceTaxId = Session.Contents["practiceTaxId"].ToString();
            mpracticeTaxId = Convert.ToInt32(practiceTaxId);   <----------------Error Occurs Here


Here is the exception detail:

System.OverflowException was unhandled by user code
  HResult=-2146233066
  Message=Value was either too large or too small for an Int32.
  Source=mscorlib
0
Comment
Question by:kwh3856
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 250 total points
ID: 39257857
It means that it can't fit in an INT32 field, it's either bigger than 2^31-1 (2147483647) or its a negative number too big to fit in that many bits.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 39257912
If it's too big, switch to Int64, otherwise known as "long".
0
 

Author Closing Comment

by:kwh3856
ID: 39275060
Sorry for the delay in getting back.  Thank you both.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question