Value was either too large or too small for an Int16

Posted on 2009-02-19
Last Modified: 2013-11-27
hi .
i need help solving this error message . We have a vb home made intranet done a few years ago in VB .net 2003 . that intranet was running till today with no issues . No code was changed since we dont have any coder around . I believe this can be related to something else, the website runs in IIS and connects to a sql 2005 database .
It uses framework 1.1.4322.2407 .

the error appears when we are selecint options in a combo box . error below ...

Server Error in '/gescom' Application.

Value was either too large or too small for an Int16.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OverflowException: Value was either too large or too small for an Int16.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:

[OverflowException: Value was either too large or too small for an Int16.]
   System.Int16.Parse(String s, NumberStyles style, IFormatProvider provider) +129
   System.Convert.ToInt16(String value) +19
   gescom.Forms.adicionar_fx.RAD_Currency_SelectedIndexChanged(Object o, RadComboBoxSelectedIndexChangedEventArgs e) in C:\gescom\forms\adicionar_fx.ascx.vb:248
   Telerik.WebControls.RadComboBox.x7256c9328041ce80(RadComboBoxSelectedIndexChangedEventArgs xfbf34718e704c6bc) +62
   Telerik.WebControls.RadComboBox.x4c7bbe559e842fc5() +54
   System.Web.UI.Page.RaiseChangedEvents() +115
   System.Web.UI.Page.ProcessRequestMain() +1099


Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407

all help is welcome .. thankz in advance .
Question by:lccviper
    LVL 19

    Accepted Solution

    An int16 holds a value between negative 32768 to positive 32767.   Combo boxes inherently have this limit in Windows for the number of items.  I would expect you are trying to add more than 32767 items to the combo box & that is generating the error.

    If this is truly the case, I would reviewing exactly what you are populating the combo box with & seeing if there is a better case for the user interaction.
    LVL 1

    Author Comment

    well althought i didnt understand quite right what your saying, the number 32767 did ring me a bell .
    so, looking at it from a user side .
    user logs into the intranet, user goes to a table to update the local currency rate for the day, this changes sometimes during the day, so the user have to update it several times a day . Every site/agency we have does this procedure also .. The data are inserted into a table in SQL , that is currently in row 32772 . does this makes sense to you ?
    the error is then displayed when the user goes to another page, selects from a combo box buy or sell, then from another combo box, selects the currenty ( then probably performs somekind of operation that will get the current currency value from sql that was previousily inserted ) .. when he clicks the currency the error is displayed .. can this be because the rates table have 32772 rows on it ?
    how can solve this, without messing in .net ?
    LVL 19

    Expert Comment

    Are you attempting to populate the combo box with more than 32767 rows or are you just referencing row 32772?
    LVL 19

    Expert Comment

    Attempting to read between the lines, are you displaying all the currency changes from an SQL statement?  If so, you could try adding a TOP xx to the SQL statement to force it to return only, say, 30000 rows.
    LVL 1

    Author Comment

    ok barthax, your comments are really valuable to me ... seems the issue is really that .. the number of rows in the table . im not a asp coder, but can do a few in sql .
    when the user opens the currency type to select, it only appears a list with the currency name followed by the actual rate ( ie: USD 1.333 ) . Theres only about 10 currencies in our system , so the combo box only displays the actual number of currencies witch is 10 , but probably is getting the rate from the rate table so it can appear after the currency name .
    the ID of the table is using identity, and is defined has integer .
    What i did to solve this so users can use the platform was issuing the command in sql

          'currates' ,
          reseed, 100

    dont know if its the correct way to do this, but it worked, users are not able to select the currency from the list without displaying that error . I believe rate ID table started from something like 20000, dunno why it was done like this .
    can you please give me some feedback has this was a correct procedure to do . I believe sometime i have to archive this table, since it will fill up in the future again , tryed to change the table ID to bigint, but didnt work well .
    guess this is a programming mistake from the company that made the platform, and not actually a error from the system .

    thankz in advance
    LVL 1

    Author Closing Comment

    will accept your solution , since it guided me throught the problem .
    thankz .. if you could comment my other post, ill aprecciate it .
    many thankz,
    LVL 19

    Expert Comment

    Thanks for the points.  Unfortunately, I'm coming at the problem from the wrong direction (low-level windows programmer) to know precisely what is going on in the C# framework+SQL interaction - it was just obvious from the stack trace where the resultant problem lay.

    I really don't know about the reseeding of the DB either, sorry.  Unfortunately, I'm at the high-end of knowledge there & not the low-level. :(  I expect your reseeding (after having read ) will result in a cure for the immediate issue, but may result in adverse effects if you've got none-integrity links in other tables' foreign indexes.  Disclaimer: I may have misunderstood the process of reseeding.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now