如何用SqlConnection类的InfoMessage事件来显示Stored Procedure的PRINT讯息。
(華版)
我想很多程序员都会面对一个问题。。。就是如何调试(Debug)Stored Procedure;以下是我在研究ADO.NET时所得到的心得,在此跟大家分享以下。
只需在VB.NET或C#代码里,添加SqlConnect_InfoMessage事件,然后就从SqlInfoMessageEventArgs读取所有的PRINT/ERROR讯息就可以了 。
所返回的讯息种类:
Source = The class that return the information.
Error = T-SQL/Database error number.
Server = SQL error serverity (please refer to MSDN for detail information).
Line = The line number of the T-SQL that cause the output.
Message = Output/Error message.
以下是Stored Procedure的代码,
浙公网安备 33010602011771号