Professional Web Applications Themes

Raising error from SPROc in VBS Script - Microsoft SQL / MS SQL Server

Hi all, I'm calling a SPROC from a vbs file (wsf) and try to raise an error, i.e. interrupt script execution based on raising an error in the SPROC. Here's what I do in the SPROC: SET strErrorMessage = 'My Error Message' +char(10) RAISERROR (strErrorMessage, 1, 2) WITH SETERROR ROLLBACK TRANSACTION MyTran RETURN 50000 When I call the SPROC from Query yzer, everyting works fine and I can see the error message in the output. BTW, what do I need to do to write the error in the SQL error log ? When calling the SPROC from the vbs script, ...

  1. #1

    Default Raising error from SPROc in VBS Script

    Hi all,

    I'm calling a SPROC from a vbs file (wsf) and try to raise
    an error, i.e. interrupt script execution based on raising
    an error in the SPROC.
    Here's what I do in the SPROC:

    SET strErrorMessage = 'My Error Message' +char(10)
    RAISERROR (strErrorMessage, 1, 2) WITH SETERROR
    ROLLBACK TRANSACTION MyTran
    RETURN 50000

    When I call the SPROC from Query yzer, everyting works
    fine and I can see the error message in the output.
    BTW, what do I need to do to write the error in the SQL
    error log ?

    When calling the SPROC from the vbs script, the script
    goes over the error and continues executing. Here's what I
    do:
    'mcon is my database connection
    if mcon.errors.count > 0 or Err.Number <> 0 then
    .... ;doing some custom error logging
    Err.Raise 50000
    mcon.errors.clear
    Else
    ....

    As I said, the error is never registered in the vbs script.
    Any help in this matter is greatly appreciated!

    Andreas
    Andreas Guest

  2. #2

    Default Re: Raising error from SPROc in VBS Script

    use xp_logevent to write to the sql server error log and windows event
    viewer

    "Andreas Heid" <com> wrote in message
    news:041801c35092$2cf18960$gbl... 


    Partha Guest

  3. #3

    Default Re: Raising error from SPROc in VBS Script

    Thanks for your reply.
    Thwt solves half of my problem. The other half is: how can I achieve
    that the VBS script notices the error and stops execution ?

    Thanks

    Andreas


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Andreas Guest

  4. #4

    Default Re: Raising error from SPROc in VBS Script

    That answers half of my question.
    The other half is: how can I make the VBS script recognize
    the error and do error handling instead of continuing
    execution as normal ?

    Thanks.

    Andreas
     
    windows event [/ref]
    raise [/ref]
    raising [/ref]
    works [/ref]
    what I [/ref]
    script. 
    >
    >
    >.
    >[/ref]
    Andreas Guest

  5. #5

    Default Re: Raising error from SPROc in VBS Script

    You are using a Severity Level of 1 (second parameter in your Raiserror
    call)
    This is considered to be an Informational message and will likely not cause
    and error condition in the calling language

    You should use a severity from 11 to 16 to cause an error to be generated.
    See Raiserror Severity Levels in BOL

    "Andreas Heid" <com> wrote in message
    news:041801c35092$2cf18960$gbl... 


    David Guest

Similar Threads

  1. SPROC Question, what am I doing wrong?
    By dj shane in forum Coldfusion Database Access
    Replies: 2
    Last Post: January 25th, 10:31 PM
  2. SPROC vs Inline Times.
    By dj shane in forum Coldfusion Database Access
    Replies: 6
    Last Post: September 22nd, 05:50 PM
  3. sproc in DW asp.net
    By Laura K in forum Dreamweaver AppDev
    Replies: 0
    Last Post: May 12th, 09:10 PM
  4. SPROC parameters
    By RobGT in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 24th, 03:38 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139