[英]Getting the error in passing parameter to a stored procedure
I have the following stored procedure: 我有以下存储过程:
ALTER PROCEDURE sp_InsertHashBinMinHash
@Id INT,
@HashBin BIGINT,
@HashTable INT,
@SubFingerprintId BIGINT,
@Seqno INT
AS
INSERT INTO HashBinsMinHash (
HashBin,
HashTable,
Seqno,
SubFingerprintId
) OUTPUT inserted.Id
VALUES
(
@HashBin, @HashTable, @Seqno, @SubFingerprintId
);
When I am running the program I am getting the following error: 当我运行程序时,出现以下错误:
procedure or function sp_insertHashBin expects parameter @Seqno which was not supplied
过程或函数sp_insertHashBin需要未提供的参数@Seqno
But I am passing 4 parameters to procedure 但是我将4个参数传递给过程
There is your problem: sp_InsertHashBinMinHash
expects 5 parameters ( Id
, HashBin
, HashTable
, SubFingerprintId
and Seqno
). 有您的问题:
sp_InsertHashBinMinHash
需要5个参数( Id
, HashBin
, HashTable
, SubFingerprintId
和Seqno
)。 You are only calling it with 4. So one is missing. 您只用4来调用它。因此缺少一个。
I would rewrite it as 我将其重写为
ALTER PROCEDURE sp_InsertHashBinMinHash
@HashBin BIGINT,
@HashTable INT,
@SubFingerprintId BIGINT,
@Seqno INT,
@Id INT OUT
AS
BEGIN
INSERT INTO HashBinsMinHash (
HashBin,
HashTable,
Seqno,
SubFingerprintId
)
VALUES
(
@HashBin, @HashTable, @Seqno, @SubFingerprintId
);
set @Id = SCOPE_IDENTITY();
select @id
END
And, passing values to your procedure from C#, add parameter @Id with proper Direction property. 并且,将值从C#传递到您的过程,并使用适当的Direction属性添加参数@Id。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.