Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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