Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

arithmetic overflow error for data type tinyint,value = 256

Tags:

sql-server

byte number = 1; add(number); // form .cs

public static int Add( byte? order)
{
  arParams[0] = new SqlParameter("@number", (number.HasValue) ? ((object)number) : DBNull.Value);
  // stored procedure call is made which takes paramaters, 
}

Stored procedure looks like this

@number tinyint
AS
BEGIN
IF @number IS NOT NULL
BEGIN
  UPDATE 
    table1
  SET 
    number = number + 1
  WHERE 
    id=13
END
INSERT INTO 
 table1
(
  number
)
VALUES 
( 
  number=@number
)

///////why i am getting this error can any one illustrate please and how do i solve this

like image 740
Tenzin Avatar asked Jan 28 '26 12:01

Tenzin


1 Answers

The range of tinyint is 0-255.

You're attempting to put 256 into a datatype that doesn't know what 256 is.

int, bigint, smalltint and tinyint ranges.

like image 111
Paul Alan Taylor Avatar answered Jan 30 '26 02:01

Paul Alan Taylor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!