Combining SQL `raiserror` with `select` in C# -
i want know if there way of using both sql raiserror
, retrieving selected result in c#. executereader()
in c# throw exception when raiserror
occurs, still want use reader capture data returned.
below simplified example. if not possible use raiserror
general cases , select
specific cases.
if (some-error) begin select @message = 'error: script made booboo', @state = 'state info' raiserror (@messsage, 16, 1) goto exit_sp end exit_sp: select @message 'message', @state 'state'
if lower severity 10 or below (from memory) not raise exception, available via infomessage
event on connection. note, however, because of how tds works, should ensure read()
etc end of all results; example, if have multiple select
s , then raiserror
, , read first select
before dropping data-reader, there chance won't see message (the tds killed).
Comments
Post a Comment