I have a stored procedure that contains the following code:
IF @somevar IS NULL
BEGIN
RAISERROR (N'Station %d does not exist.', -- Message text.
10, -- Severity,
7, -- State,
@id);
END
I want to catch the SqlException in C# code. But that exception is not raised. What am I doing wrong?
Thanks.
I believe you need a higher severity level; try it with a severity of at least 11. Also, are you using ExecuteScalar - which seems to eat exceptions? See here.