How to get RAISERROR severity info in Visual Basic

  • is there a way to recuperate in visual basic the severity level of an error raised by RAISERROR inside a sp.

    I looked into the ADODB.Error object of the ADODB.Connection object but did not find any property that contains the severity of the Raiserror command.

    Bart

  • This was removed by the editor as SPAM

  • did you try to pass it as an output parameter from SP?

    Regards,Yelena Varsha

  • Adding an extra output parameter to all stored procedures would have an important impact on all stored procedures and vb code.  And it would only work when the stored procedure completes in a normal way.

    I'm looking in using the severity property of RAISERROR to make a distinction between the different errors that can occure in the sp. (Ex simple warning, critical error, improper use, ....) This info should be returned to vb so that the GUI knows how to display the msgs.

  • Not that I am aware of.

    The only way I can think of getting the severity is to query the master.dbo.sysmessages table.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • When you catch an sqlexception, it has an sqlerror object, which has a property "Class". this is the severity value in sql server. the sqlerror class has other properties like Source, Message, LineNumber etc.

     

  • I'm still on the VB6 platform with this project. Do you know if there is an equivalent for the sqlexception object in VB6? I checked the ADODB.Error object but it doesn't have the 'class' property you mentioned. This obcjet only has following properties : 'Description,HelpContext,HelpFile,NativeError,Number,Source,SQLState' !

    AS i'm working on a shared sql production server I do not have access to the  master.dbo.sysmessage table. Therefor I make my RAISERROR msgs inline, and can't use a query on sysmessage table afterwards to find back the severity level.

    Example of a raiserror msg inmy tsql code:

    RAISERROR( 'You are not authorized to enter measurements for physical stock %d.',16,1,@PhystockID)

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

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