Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Posts
    3

    Unanswered: XP error handling problem

    I have an extended stored proc which uses sqlexecdirect to execute about 4 lines of sql including a call to sp_addrolemember.

    The problem I am getting is that if the called code fails and calls Raiserror ("msg",16,1), it is still passed back to the calling XP as SQL_SUCCESS_WITH_INFO and not SQL_ERROR as I expected.

    As far as I can see, any raiserror with a severity above 10 should be returned as an error.

    Also, any suggestions as to how error handling can be added around the call to sp_addrolemember ? It uses Raiserror("msg",-1,-1) for every msg ie errors and success. There is a return status but Im not sure if this is reliable once the raiserror has been called.

    Any guidance would be appreciated :-)

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Is this being executed within sql server or through programming code (like vb, c++ ...) ?

  3. #3
    Join Date
    Dec 2002
    Posts
    3
    The extended stored proc is written in C++ which checks the result of SQLExecDirect and attempts to decipher whether there is a warning or error via SQLGetDiagField.

    The XP is called from C# code.

  4. #4
    Join Date
    Dec 2002
    Posts
    3
    I have got a work around that uses SQLGetDiagField with the severity parameter which returns the severity used in the raiserror statement

    It would still be useful to know why Raiserror "msg",16,1 returns success_with_info instead of the documented sql_error.

  5. #5
    Join Date
    Feb 2002
    Posts
    2,232
    Which version of sql server are you using ? Have you tried to run the extended sp on the sql server in qa ? When connecting from c#/c++ - what driver are you using ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •