我写了一个简单的存储过程,我无法在代码中找到问题
存储过程:
ALTER PROCEDURE dbo.BestellDetail_Delete
-- Add the parameters for the stored procedure here
@RefId AS int
AS
-- Insert statements for procedure here
DELETE FROM BestellDetails
WHERE RefBestellId = @RefId
RETURN
C#代码
SqlCommand cmdBestellDetailsDELETE = new SqlCommand("BestellDetail_Delete", conn);
cmdBestellDetailsDELETE.Parameters.AddWithValue("@RefId", 35);
cmdBestellDetailsDELETE.ExecuteNonQuery();
错误:
过程或函数'BestellDetail_Delete'需要参数'@RefId',这是未提供的。
那么请有人告诉我这里我做错了什么?
答案 0 :(得分:4)
缺少
cmdBestellDetailsDELETE.CommandType = CommandType.StoredProcedure;
如果没有该标志,命令类型默认为CommandType.Text,因此它应该是“SELECT ....”,“DELETE ....”