C# 无法将X取消为Int

C# 无法将X取消为Int,c#,parameters,unboxing,C#,Parameters,Unboxing,我有这个sql参数,我得到了不能取消装箱的int错误 returnValue = (int)cmdUpdateCreatedOn.Parameters["@intcount"].Value; 返回值声明为int returnValue=0 我的参数也声明为int,它将更新行的行数。 我尝试过不同的转换语法,但没有一种有效 我的SP是 ALTER Procedure [dbo].[UpdateStation] @intcount int output AS select S

我有这个sql参数,我得到了不能取消装箱的int错误

returnValue = (int)cmdUpdateCreatedOn.Parameters["@intcount"].Value;
返回值声明为int returnValue=0 我的参数也声明为int,它将更新行的行数。 我尝试过不同的转换语法,但没有一种有效

我的SP是

ALTER Procedure [dbo].[UpdateStation]
@intcount int output AS 
select StationaryName into #stname from Stationaries where Authorized = 0 
select * from #stname 
Update Stationaries Set  Authorized = 1 where Authorized = 0 set @intcount =   @@rowcount
我也有同样的问题

存储过程中返回的INT类型为“SHORT”。我不知道为什么

无法施放…@SubjectID”。。。(实际类型为'short')到'string'

解决方案:
1.在c#或

2.在c#中使用Convert.ToInt32。

查看调试器中的值。价值是什么?它是什么类型的?我的钱花在值可以为null的int或实际为
null
,但不管是什么问题,都很容易解决。您得到的确切错误是什么?在调试器中,它的值是int,并且它说,无法取消“cmdUpdateCreatedOn”参数[“@intcount”].Value'作为一个整数你确定你从数据库中得到了一个
int
?取消装箱要求您在将其强制转换为所需类型之前取消装箱到装箱时所使用的原始类型。你是否有可能将其装箱,或者DB装箱到不同的值类型?你最好在你的问题csharper中将其作为更新。