Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How do I trap the results of a RAISERROR and use in an ASP page?


Message #1 by "Gail" <playhard@m...> on Thu, 18 Jan 2001 00:20:23 -0000
Hi,

Does anyone know of a way to trap if a RAISERROR message was executed, and

send that back to a variable in an ASP page?



Here is my stored Procedure:

REATE PROCEDURE dbo.sp_PassFail

@t_DeviceOS char(20)= null,

@t_DeviceRAM char(10) = null,

@t_DeviceRAMOther int = null,

@t_DeviceBrowser char(20) = null,

@t_DeviceBrowserVer char(30) = null,

@t_Line1kbps decimal(18,0) = null,

@t_Line2kbps decimal(18,0) = null,

@t_Line3kbps decimal(18,0) = null,

@out_passfail char(10) OUTPUT



AS



SET @out_passfail = 'p'

 

IF @t_DeviceOS = 'other'

BEGIN

RAISERROR (50001, 10, 1)

SET @out_passfail = 'f'

END



IF (@t_DeviceRAM = null) AND  (@t_DeviceRAM < 32)

BEGIN

RAISERROR (50002, 10, 1)

SET @out_passfail = 'f'

END





IF @t_DeviceBrowser <> 'msie'

BEGIN

RAISERROR (50003, 10, 1)

SET @out_passfail = 'f'

END





IF @t_DeviceBrowserVer = 'other'

BEGIN

RAISERROR (50004, 10, 1)

SET @out_passfail = 'f'

END



IF (@t_Line1kbps

<= 40000) OR (@t_Line2kbps <= 40000) OR (@t_Line3kbps <= 40000)

BEGIN

RAISERROR (50005, 10, 1)

SET @out_passfail = 'f'

END





I would like to store the results of each RAISERROR in a variable in an

ASP page.  Is there some easy way to access whether or not Error 50003 was

raised and dump that into a variable in ASP, or is the only way to do this

is by creating a separate output parameter for each potential error, and

set that in the stored procedure?

Message #2 by "Wally Burfine" <oopconsultant@h...> on Thu, 18 Jan 2001 14:03:35 -0000
you check the conn.error collection





>From: "Gail" <playhard@m...>

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] How do I trap the results of a RAISERROR and use 

>in an ASP page?

>Date: Thu, 18 Jan 2001 10:43:16 -0800

>

>Hi,

>Does anyone know of a way to trap if a RAISERROR message was executed, and

>send that back to a variable in an ASP page?

>

>Here is my stored Procedure:

>REATE PROCEDURE dbo.sp_PassFail

>@t_DeviceOS char(20)= null,

>@t_DeviceRAM char(10) = null,

>@t_DeviceRAMOther int = null,

>@t_DeviceBrowser char(20) = null,

>@t_DeviceBrowserVer char(30) = null,

>@t_Line1kbps decimal(18,0) = null,

>@t_Line2kbps decimal(18,0) = null,

>@t_Line3kbps decimal(18,0) = null,

>@out_passfail char(10) OUTPUT

>

>AS

>

>SET @out_passfail = 'p'

>

>IF @t_DeviceOS = 'other'

>BEGIN

>RAISERROR (50001, 10, 1)

>SET @out_passfail = 'f'

>END

>

>IF (@t_DeviceRAM = null) AND  (@t_DeviceRAM < 32)

>BEGIN

>RAISERROR (50002, 10, 1)

>SET @out_passfail = 'f'

>END

>

>

>IF @t_DeviceBrowser <> 'msie'

>BEGIN

>RAISERROR (50003, 10, 1)

>SET @out_passfail = 'f'

>END

>

>

>IF @t_DeviceBrowserVer = 'other'

>BEGIN

>RAISERROR (50004, 10, 1)

>SET @out_passfail = 'f'

>END

>

>IF (@t_Line1kbps

><= 40000) OR (@t_Line2kbps <= 40000) OR (@t_Line3kbps <= 40000)

>BEGIN

>RAISERROR (50005, 10, 1)

>SET @out_passfail = 'f'

>END

>

>

>I would like to store the results of each RAISERROR in a variable in an

>ASP page.  Is there some easy way to access whether or not Error 50003 was

>raised and dump that into a variable in ASP, or is the only way to do this

>is by creating a separate output parameter for each potential error, and

>set that in the stored procedure?

>

Message #3 by "Dallas Martin" <dmartin@z...> on Thu, 18 Jan 2001 19:08:40 -0500
In your proc declaration, include an OUT parameter.

Set it equal to @@ERROR inside your proc.



SELECT @OUTVALUE = @@ERROR



CREATE PROCEDURE sp_dothis

(@input VARCHAR(100),

@OUTVALUE INT)

AS

UPDATE table1 SET @field1 = @input

IF @@ERROR <> 0

BEGIN

   SELECT @OUTVALUE = @@ERROR

  RETURN

END



SELECT @OUTVALUE = 0

RETURN







END





Use the ADODB.Command Object



----- Original Message -----

From: "Gail" <playhard@m...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, January 18, 2001 1:43 PM

Subject: [asp_databases] How do I trap the results of a RAISERROR and use in

an ASP page?





> Hi,

> Does anyone know of a way to trap if a RAISERROR message was executed, and

> send that back to a variable in an ASP page?

>

> Here is my stored Procedure:

> REATE PROCEDURE dbo.sp_PassFail

> @t_DeviceOS char(20)= null,

> @t_DeviceRAM char(10) = null,

> @t_DeviceRAMOther int = null,

> @t_DeviceBrowser char(20) = null,

> @t_DeviceBrowserVer char(30) = null,

> @t_Line1kbps decimal(18,0) = null,

> @t_Line2kbps decimal(18,0) = null,

> @t_Line3kbps decimal(18,0) = null,

> @out_passfail char(10) OUTPUT

>

> AS

>

> SET @out_passfail = 'p'

>

> IF @t_DeviceOS = 'other'

> BEGIN

> RAISERROR (50001, 10, 1)

> SET @out_passfail = 'f'

> END

>

> IF (@t_DeviceRAM = null) AND  (@t_DeviceRAM < 32)

> BEGIN

> RAISERROR (50002, 10, 1)

> SET @out_passfail = 'f'

> END

>

>

> IF @t_DeviceBrowser <> 'msie'

> BEGIN

> RAISERROR (50003, 10, 1)

> SET @out_passfail = 'f'

> END

>

>

> IF @t_DeviceBrowserVer = 'other'

> BEGIN

> RAISERROR (50004, 10, 1)

> SET @out_passfail = 'f'

> END

>

> IF (@t_Line1kbps

> <= 40000) OR (@t_Line2kbps <= 40000) OR (@t_Line3kbps <= 40000)

> BEGIN

> RAISERROR (50005, 10, 1)

> SET @out_passfail = 'f'

> END

>

>

> I would like to store the results of each RAISERROR in a variable in an

> ASP page.  Is there some easy way to access whether or not Error 50003 was

> raised and dump that into a variable in ASP, or is the only way to do this

> is by creating a separate output parameter for each potential error, and

> set that in the stored procedure?


  Return to Index