Solved

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

Posted on 2013-06-18
3
3,775 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
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 85

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

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 …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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