I want to know if there is a way of using both SQL raiserror
and retrieving the selected result in C#. ExecuteReader()
in C# will throw an exception when raiserror
occurs, but I still want to use the reader to capture any data returned.
Below is a simplified example. If this is not possible I will use raiserror
for general cases and select
for specific cases.
if (some-error)
begin
select @Message = 'ERROR: script made a booboo',
@State = 'State Info'
raiserror (@Messsage, 16, 1)
goto exit_sp
end
exit_sp:
select @Message 'Message', @State 'State'