We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Value was either too large or too small for an Int16

Medium Priority
6,488 Views
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 .
Comment
Watch Question

CERTIFIED EXPERT
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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 ?
CERTIFIED EXPERT

Commented:
Are you attempting to populate the combo box with more than 32767 rows or are you just referencing row 32772?
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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 .
[CurRateId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
What i did to solve this so users can use the platform was issuing the command in sql

DBCC CHECKIDENT
(
      '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

Author

Commented:
will accept your solution , since it guided me throught the problem .
thankz .. if you could comment my other post, ill aprecciate it .
many thankz,
mario
CERTIFIED EXPERT

Commented:
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 http://technet.microsoft.com/en-us/library/ms176057.aspx ) 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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.