如何解决“过程或函数指定了太多参数"?例外? [英] How to solve "Procedure or function has too many arguments specified" exception?
问题描述
我有几个用于更新不同表的存储过程.当我执行它们时,出现如下异常
I have several stored procedures for updating different tables. And when I execute them I get the exception as follows
过程或函数指定了太多参数
Procedure or function has too many arguments specified
我尝试了在互联网上找到的答案,但无法解决.
这是我的一个存储过程的代码
I tried answers found on over the internet but couldn't fix it.
Here is my code for one stored procedure
cmd.CommandText = "update_HS_HR_EMP_BANK_AADM";
cmd.Parameters.Add("@appNo", SqlDbType.VarChar).Value = appNo;
cmd.Parameters.Add("@BRANCH_CODE", SqlDbType.VarChar).Value = branch;
cmd.Parameters.Add("@ACCOUNTNO", SqlDbType.VarChar).Value = account;
cmd.Parameters.Add("@ACCOUNT_TYPE", SqlDbType.VarChar).Value = type;
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
这是我的存储过程
ALTER PROCEDURE [dbo].[update_HS_HR_EMP_BANK_AADM]
@appNo int,
@BRANCH_CODE VARCHAR(10),
@ACCOUNTNO VARCHAR(50),
@ACCOUNT_TYPE VARCHAR(1)
AS
BEGIN
Update [HS_HR_EMP_BANK_AADM]
SET
[BBRANCH_CODE]=@BRANCH_CODE
,[EBANK_ACC_NO]=@ACCOUNTNO
,[EBANK_ACC_TYPE_FLG]=@ACCOUNT_TYPE
,[EBANK_ACTIVE_FLAG]=1
,[LAST_MODIFIED_DATE]=GETDATE()
Where App_no=@appNo
END
推荐答案
您应该尝试研究的几件事
There are few things that you should try to investigate
检查连接字符串以检查它是否在正确的数据库中
Check the connection string to check it is hitting the right database
尝试指定命令类型:
cmd.CommandType = System.Data.CommandType.StoredProcedure;
并将您要传入的appNo的参数类型从Varchar更改为Int.
And change the parameter type you are passing in for the appNo from Varchar to Int.
cmd.Parameters.Add("@appNo", SqlDbType.VarChar).Value = appNo;
根据存储的proc,它应该是int.
As per the stored proc, it should be int.
cmd.Parameters.Add("@appNo", SqlDbType.Int).Value = appNo;
这篇关于如何解决“过程或函数指定了太多参数"?例外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!