The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output

…衆ロ難τιáo~ 提交于 2020-01-02 01:59:29

问题


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.

I tried to set @mode as output like this:

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.


回答1:


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

ALTER PROCEDURE spCertificationType 

     @mode int,
     @result nvarchar(15) output
 AS
 BEGIN
     if @mode = 1
   begin
    exec spGeneratedID 2, @result output
    print @result
   end
END



回答2:


I fixed this error a different way.

  1. I had removed the OUTPUT statement after a parameter in my SP.
  2. I then got the error.
  3. 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.


来源:https://stackoverflow.com/questions/32219733/the-formal-parameter-mode-was-not-declared-as-an-output-parameter-but-the-ac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!