c#.NET如何调用存储过程,还有就是如何调用,输出返回值?
ALTERPROCEDURE[dbo].[addCate]--Addtheparametersforthestoredprocedurehere@errorintoutp...
ALTER PROCEDURE [dbo].[addCate]
-- Add the parameters for the stored procedure here
@error int output,
@cateID bigint,
@cate varchar(100)
AS
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
if not exists(select * from bookcategory where cateID=@cateID or category=@cate)
BEGIN
insert into bookcategory(cateID,category) values(@cateID,@cate)
set @error=1
return @error
END
else
BEGIN
set @error=0
return @error
end
存储过程设计是这样,用的时候老是说要提供参数,我只是想看那个返回值判断是否插入成功而已! 展开
-- Add the parameters for the stored procedure here
@error int output,
@cateID bigint,
@cate varchar(100)
AS
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
if not exists(select * from bookcategory where cateID=@cateID or category=@cate)
BEGIN
insert into bookcategory(cateID,category) values(@cateID,@cate)
set @error=1
return @error
END
else
BEGIN
set @error=0
return @error
end
存储过程设计是这样,用的时候老是说要提供参数,我只是想看那个返回值判断是否插入成功而已! 展开
展开全部
conn = GetConnection();
conn.Open();
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "存储过程名字";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p = new SqlParameter("@id", SqlDbType.Int);
p.Direction = ParameterDirection.Output;
cmd.Parameters.add(s);
cmd.exenonquery();
string value=s.value.toString();
}
conn.Open();
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "存储过程名字";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p = new SqlParameter("@id", SqlDbType.Int);
p.Direction = ParameterDirection.Output;
cmd.Parameters.add(s);
cmd.exenonquery();
string value=s.value.toString();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询