SQL 形参“@mode”没有声明为OUTPUT参数,而是请求输出中传入的实参
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32219733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output
提问by roger bulawan
I have this stored procedure:
我有这个存储过程:
ALTER PROCEDURE spCertificationType
@result nvarchar(15) output,
@mode int
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
but when I tried to execute it,it has this error
但是当我尝试执行它时,它有这个错误
The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.
形式参数“@mode”并未声明为 OUTPUT 参数,而是在请求的输出中传递的实际参数。
I tried to set @mode
as output like this:
我试图设置@mode
为这样的输出:
ALTER PROCEDURE spCertificationType
@result nvarchar(15) output,
@mode int output
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
but the it returns a null value.
但它返回一个空值。
Any fix for this? Thanks in advance.
有什么解决办法吗?提前致谢。
回答by david sam
the sequence of parameter in store procedure is that first use input parameter then use output parameter:- you can see this link for more knowledge of store procedure:-
存储过程中的参数顺序是先使用输入参数,然后使用输出参数:-您可以查看此链接以获取更多存储过程知识:-
http://www.codeproject.com/Articles/126898/Sql-Server-How-To-Write-a-Stored-Procedure-in-SQL
http://www.codeproject.com/Articles/126898/Sql-Server-How-To-Write-a-Stored-Procedure-in-SQL
ALTER PROCEDURE spCertificationType
@mode int,
@result nvarchar(15) output
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
回答by user7502347
I fixed this error a different way.
我以不同的方式修复了这个错误。
- I had removed the OUTPUT statement after a parameter in my SP.
- I then got the error.
- I then went back to the SQLDataSource Configure Data Source wizard and went through the steps again. I discovered that changing the SP made the wizard delete the settings associated with the parameter that used to have OUTPUT after it.
- 我在 SP 中的参数之后删除了 OUTPUT 语句。
- 然后我得到了错误。
- 然后我返回到 SQLDataSource 配置数据源向导并再次执行这些步骤。我发现更改 SP 会使向导删除与参数相关联的设置,这些设置之前带有 OUTPUT。