Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value was either too large or too small for an Int32 Error [duplicate]

I am trying to add Mobile Number to my column which is of 10 digit

But it is giving me error as

Value was either too large or too small for an Int32

Here is the code

drpartyInfo[0]["MOB_NUM"] = string.IsNullOrWhiteSpace(e.Record["MOB_NUM"].ToString())
    ? DBNull.Value : (object)Convert.ToInt32(e.Record["MOB_NUM"].ToString());
like image 323
Nad Avatar asked Mar 11 '23 02:03

Nad


2 Answers

Better you should use long, string or byte array.

You can refer this.

short.MaxValue:  32767
short.MinValue: -32768
ushort.MaxValue: 65535
ushort.MinValue: 0
int.MaxValue:    2,147,483,647
int.MinValue:   -2,147,483,648
uint.MaxValue:   4,294,967,295
uint.MinValue:   0
long.MaxValue:   9,223,372,036,854,775,807
long.MinValue:  -9,223,372,036,854,775,808
ulong.MaxValue:  18,446,744,073,709,551,615

You can use unsigned datatype, if you are sure that it will always be positive number.

like image 85
vivek nuna Avatar answered Apr 26 '23 17:04

vivek nuna


Mobile number can not be stored on int, change your type to string

like image 25
kgzdev Avatar answered Apr 26 '23 16:04

kgzdev