Handling errors in TSQL and intercepting them in VB

  • I am a VB6 developer who uses database techniques as part of my software development skills. Since I started dabbling in SQL Server 2000, I like it more with every passing week as I continue to learn new techniques which let me move a lot of my code out of VB to SQL. The end result is it makes my projects much better and elegant too. And this site has really helped me gain in skills. Thank you all.

    I would like to acquire one must-have skill yet: I would like to build error handling in my sprocs, but since my users will be using SQL Server indirectly (via my app), I want to be able to intercept those TSQL error messages with VB6.

    I shall be glad to receive any help.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • Error handling in sql 2000 is a tricky process.

    You have to evaluate after each statement. Some errors immediately abort the batch.

    statement

    /*saving the error*/

    @myvar=@@error

    if @myvar<>0

    BEGIN

    doerrorhandling

    END

    statement

    @myvar=@@error

    if @myvar<>0

    BEGIN

    doerrorhandling

    END

    Inside the stored procedures you will only have the error number.

    The errors (number, description,...) come back in the errors collection.

    You may raise an error with RAISERROR

  • Thank you for trying to help, Jo, but, no offence intended, I must confess that I am none the wiser after reading your post.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • I am still waiting for help on how to implement error handling in SQL Server 2000 and how to intercept those errors in VB6.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • Thanks again, Jo, I had a look at it.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply