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=@num开发者_运维问答ber
)
///////why i am getting this error can any one illustrate please and how do i solve this
It is because you cannot set the Tinyint value beyond 255 and below 0. So you should apply validation before sending it to database.
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.
精彩评论