如何使用c#在asp.net网站上显示存储过程的提升错误 [英] how to show Raise Error of Stored procedure in asp.net web site using c#
本文介绍了如何使用c#在asp.net网站上显示存储过程的提升错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有asp.net网站使用c#
n后端sql server 2008 r2。
我正在编写存储过程以便插入。
在我的存储过程中。
i写了这段代码:
Hi guys,
I have asp.net website using c#
n backend sql server 2008 r2.
where i'm writing stored procedure for insertion.
in my stored procedure.
i have written this code:
IF EXISTS
(
SELECT * from tbl_jobposted where Posted_Date = @PostedDate and UnitID = @UnitID
)
BEGIN
RAISERROR 20000 'This Job Already Posted ! '
RETURN(1)
END
i想要显示此消息,我得到了什么从存储过程到屏幕上的用户。
我如何获取该错误并将其显示在页面上。
plz帮帮我。
谢谢
i want to show this message, what i got from the stored procedure, to the user on the screen.
how can i fetch that error n display it on the page.
plz help me.
Thanks
推荐答案
看到这个答案此处。它说,
这取决于您的RAISERROR的严重程度。严重性1-10被视为信息消息,不会破坏C#客户端的流量,即它们不会抛出异常。这些信息消息将触发InfoMessage 事件。
See this answer here. It says,
"It depends on the severity of your RAISERROR. Severities 1-10 are considered information messages and do not break the flow of your C# client, ie. they don't throw exception. These information messages will trigger the InfoMessage event on your connection."
这篇关于如何使用c#在asp.net网站上显示存储过程的提升错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文