存储过程错误 [英] stored procedure error
本文介绍了存储过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了以下存储过程:
其中有2个表arts.artistId是艺术表中的外键。
i have written following stored procedure:
in which there are 2 tables arts and artist.artistId is a foreign key in arts table.
create procedure spInsertArts(
@artsId int out,
@name varchar(50),
@category varchar(50),
@artistId int
)
as
begin
declare @artistId int
set @artistId=@@IDENTITY
if exists(select artistId from artist)
insert into arts(name,category,artistId) values(@name,@category,@artistId)
end
我收到错误:
I am getting error as:
Procedure or function spInsertArts has too many arguments specified.
请帮助
please help
推荐答案
嗯...你声明了四个参数,但是你只在你的调用中提供了三个 - 而在SP中你试图声明一个与其中一个参数同名的变量:@artistId <无线电通信/>
我怀疑你并不打算在参数列表中包含@artistId。
Um...You declare four parameters, but you only provide three in your call - and in the SP you try to declare a variable with the same name as one of the parameters: @artistId
I suspect that you didn't mean to include @artistId in the parameters list.
Quote:
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", TextBox1.Text);
cmd.Parameters.AddWithValue("@category", DropDownList1.SelectedValue);
SqlParameter output = new SqlParameter();
output.ParameterName = "@artsId";
output.SqlDbType = System.Data.SqlDbType.Int;
output.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(output);
con.Open();
cmd.ExecuteNonQuery();
您的代码中未传递参数 @artistId
。请通过并尝试。
You have not passed the parameter "@artistId
" in your code. Please pass that and try.
这篇关于存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文