我对下面的线程有类似的问题 ASP.NET MVC4 return output from a stored procedure with Entity Framework
我试过同样的事情,但我得到了错误:
Cannot assign void to an implicitly-typed local variable on
这是我的程序:
create PROCEDURE [dbo].[usp_UpdateValuesInTables]
(
@s_clientid int,
@success int output
)
AS
BEGIN
Begin Try
BEGIN TRAN
---- sql statements
COMMIT TRAN
set @success=1
End Try
Begin Catch
ROLLBACK TRAN
set @success=0
End Catch
END
和c#代码
int? success = null;
var successCode = Context.usp_UpdateValuesInTables(Convert.ToInt32(obj.SourceClientDropDown),ref success);
为什么会出现该错误?
如果我尝试将 var
替换为 int
,则会出现错误
Can not implicitly convert type void to int
最佳答案
试试这个:
int? success = null;
Context.usp_UpdateValuesInTables(Convert.ToInt32(obj.SourceClientDropDown),ref success);
var successCode = success; //success is the returned result.
关于c# - MVC4 使用 linq to sql 返回存储过程输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19077762/