[英]How can we handle MSSQL raiseerror in VB.net code behind using sqlcommand?
我编写了一个存储过程,在相同的特定条件下会引发错误。 当我使用sqlcommand使用vb.net代码调用此存储过程时,我无法捕获RAISEERROR
存放程序
Create sp_UPDATE
as
begin
IF @QTY > @ReqAlloQty
BEGIN
RAISERROR('Product Quantity should not be more than Required qty.',16,1)
goto EXITWITHERROR
END
end
VB.NET
Try
m_commDBcommand.ExecuteNonQuery()
Catch ex As Exception
Finally
End Try
匹配存储过程条件时,不会引发异常。
任何帮助将不胜感激
在rarrrror之后添加一个返回语句:
RAISERROR('Product Quantity should not be more than Required qty.',16,1);
RETURN;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.