I have read so much on the RASIERROR function and its requirements for making the exception raise in .NET, but I still can't get the exception to be rasied. Here is the SP snippet:
BEGIN
RAISERROR('This is a custom error message.', 16, 1);
RETURN;
END
And here is the .NET code snippet:
cmd.Connection = conn
cmd.ExecuteNonQuery()
'Close the db connection, and local dispose
conn.Close()
Catch ex As SQLException
Dim msg As String = ex.Message
End Try
So I think I have covered the bases:
So what am I missing? Any help is appreciated, thanks!
It works just fine for me:
SqlConnection conn = new SqlConnection("...");
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "errTest";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
conn.Open();
cmd.ExecuteNonQuery();
CREATE PROCEDURE errTest
AS
RAISERROR('This is a custom error message.', 16, 1);
RETURN;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With