Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-18
3
Medium Priority
?
3,943 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 1000 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 1000 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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