Click here to Skip to main content
15,898,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

This is the code.

CODE 1: cmd.Parameters.Add("@RateCenterID", OleDbType.Integer).Value = Convert.ToInt32(ratecenterid.Text);

CODE 2: cmd.Parameters.Add("@QuantityThreshold", OleDbType.Integer).Value = Convert.ToIn32(quantityThreshold.Text);

I get the following error in the **CODE 2** but not in CODE 1

Error: **Value was either too large or too small for an Int32.**

kindly help me

Regards,
Arjun
Posted

Use int.TryParse() method
C#
int theResult = 0;
            if (theValue == null || Convert.IsDBNull(theValue) || !int.TryParse(theValue.ToString(), out theResult))
                theResult = 0;
            return theResult;
 
Share this answer
 
OleDbType.Integer is a 16-bit integer and not 32-bit. You would need to use LongInteger instead. The value entered in quantityThreshold.Text is probably larger than 32767 (or below -32768)

Good luck!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900