ADO & Stored Proc

Results 1 to 2 of 2

Thread: ADO & Stored Proc

  1. #1
    DEJ Guest

    Default ADO & Stored Proc

    &nbsp;<BR> We have several stored procedures written on SQL Server 7.0 that use the "Print" statement to return messages to the<BR> calling<BR> program. Is there a way to call the "Print" statement from ASP? I know how to retrieve return values and output<BR> parameters,<BR> but not sure on this.... <BR><BR><BR> Example: <BR><BR> CREATE PROCEDURE stp_temp<BR> (@sPKG_CODE varchar(15) = null, <BR> @sEVENT_CODE varchar(30) = null, <BR> @sEVENT_GROUP varchar(30) = null, <BR> @sEVENT_DESC varchar(100) = null, <BR> @dACTUAL_DT datetime = null, <BR> @sLAST_USER varchar(15) = null, <BR> @dLAST_UPDATE datetime = null, <BR> @sLAST_ACTIVITY varchar(1) = null) <BR><BR> AS <BR><BR> Set nocount on <BR><BR> Declare @iErrorNumber int <BR><BR> Begin Transaction <BR> INSERT INTO PDS.dbo.PDS_HDR_EVENTS<BR> ( [PKG_CODE, <BR> EVENT_CODE, <BR> EVENT_GROUP, <BR> EVENT_DESC, <BR> ACTUAL_DT, <BR> LAST_USER, <BR> LAST_UPDATE, <BR> LAST_ACTIVITY) <BR><BR> VALUES <BR> ( @sPKG_CODE, <BR> @sEVENT_CODE, <BR> @sEVENT_GROUP, <BR> @sEVENT_DESC, <BR> @dACTUAL_DT, <BR> @sLAST_USER, <BR> @dLAST_UPDATE, <BR> @sLAST_ACTIVITY) <BR><BR> Set @iErrorNumber = @@Error <BR><BR> If (@iErrorNumber &#060;&#062; 0) <BR> Begin <BR> Print &#039Error Occurred While Processing Insert Statement on dbo.PDS_HDR_EVENTS table...&#039 <BR> Print &#039Transaction Cancelled...&#039 <BR> Rollback Transaction <BR> Return(@iErrorNumber) <BR> End <BR><BR> Commit Transaction <BR> Print &#039Record Inserted Successfully...&#039 <BR> Return 0

  2. #2
    Join Date
    Dec 1969

    Default RE: ADO & Stored Proc

    Why do you need to get the value of the print statement? If run your SP with a command object just get the Return value. If it&#039s 0 it was successfull otherwise you had an Error. You could put your error messages in an output param instead of (or as well as) using PRINT and get that with the command object also. But, I don&#039t think there is a way to access values written by PRINT.<BR><BR>HTH

Posting Permissions

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