Hi,

I have a VB.Net system that connect to SQL Server through ODBC.
When I try to raiseerror from an IF...ELSE statement, it does not triggered the exception handling.

I have done some raise error testing at my side. Below is my finding:

1. RaiseError did not triggered exception:

CREATE PROC xxx
       AS
         IF 1=1
           BEGIN
             raiserror (70000,15,15)
           END

2. RaiseError triggered exception:

CREATE PROC xxx
       AS
         IF 1=1
           BEGIN
             raiserror (70000,15,15)
             raiserror (70000,15,15)
           END


       CREATE PROC xxx
       AS
       BEGIN
         raiserror (70000,15,15)
       END

Any idea why it does not work in IF...ELSE statement?

Thank you.

KC

Recommended Answers

All 4 Replies

The severity level I used in testing is 15. By right, more than 10 should trigger exception.

try to check if it was handled by a try catch function before it reach to your designated exception error to show. Also check if the option show exception error is check/included.

Hi Jireh, There are no try catch function in between. I catch the exception in the function that call ExecuteNonQuery.

About the "show exception" checking option, I do not know where to check it. Can you show me where can I check that?

Thanks!

KC

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.