Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now