存储过程错误 [英] store procedure error
本文介绍了存储过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经制作了一个存储程序来更新管理员的数据,我的存储程序看起来像..
-------------------------------------------------- ------------
i have making one store procedure for updating the data of administrator my store procedure is look like..
--------------------------------------------------------------
ALTER PROCEDURE [dbo].[edit_admindetails]
@ID int,
@Name nvarchar(250),
@Address nvarchar(max),
@MobileNo varchar(11),
@PhoneNo varchar(20),
@EmailId varchar(50)
AS
BEGIN
UPDATE dbo.UserInfo SET
Name=@Name,
Address=@Address,
MobileNo=@MobileNo,
PhoneNo=@PhoneNo,
EmailID=@EmailID
WHERE ID=@ID
END
但是它显示出类似.............
的错误
but it shows me error like .............
Msg 201, Level 16, State 4, Procedure edit_admindetails, Line 0
Procedure or Function 'edit_admindetails expects parameter @ID, which was not supplied
任何人都可以帮助我...谢谢..
anyone help me... thanks..
推荐答案
因为在调用此存储过程时,您没有将@Id作为输入参数.
应该是这样的
Because when you are calling this stored procedure you didnt pass @Id as input parameter.
It should be like this
exec edit_admindetails 1,'namesomething','addresssoemthing','mobnosomething','phonenosomething,'emailsomthing
您可以看到我传递了6个参数
You can see i passed 6 parameters
Santosh的答案是正确的,您必须向存储过程提供所有必需的参数.
但是,如果您遇到的情况是有时您不知道参数的值,并且想要使用默认值,则可以为参数定义默认值.例如:
Santosh''s answer is correct, you have to supply all the mandatory parameters to the stored procedure.
However, if you have a situation that sometimes you don''t know a value for a parameter and you want to use a default value, you can define a default for a parameter. For example:
ALTER PROCEDURE [dbo].[edit_admindetails]
@ID int,
@Name nvarchar(250),
@Address nvarchar(max),
@MobileNo varchar(11),
@PhoneNo varchar(20),
@EmailId varchar(50) = null
AS
...
使用上面的定义,您无需提供emailid.如果未提供,则在过程内使用默认值null
.
With the definition above you don''t need to supply emailid. If it isn''t supplied, the default value of null
is used inside the procedure.
这篇关于存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文