I have a scenario where essentially I need to cancel an order from an asp page, calling a SQL stored procedure, and then the stored procedure needs to send back generic responses to be displayed or used on the ASP page...but I don't know what statements I need on the asp side and sql side to make it work?
For example:
ASP:
Dim cmdSearch, prmFields
Set cmdCancel = Server.CreateObject("ADODB.Command")
Set prmFields=cmdCancel.CreateParameter("@order_id",adNumeric,adParamInput,9, order_id)
prmFields.Precision=9
cmdAdmin.Parameters.Append prmFields
Set prmFields=cmdAdmin.CreateParameter("@customer_id",adNumeric,adParamInput,5, customer_id)
prmFields.Precision=5
cmdAdmin.Parameters.Append prmFields
cmdCancel.CommandText = "sp_cancel_order"
Then the stored procedure will look something like:
ALTER PROCEDURE [dbo].[sp_cancel_order]
--order ID passed
@order_id numeric(9,0),
--customer id passed
@customer_id numeric(5,0),
@status char(1)
AS
BEGIN
SET @status = 'A' --TEST VALUE
-- Insert statements for procedure here
IF @order_id <> '' AND @order_id IS NOT NULL
BEGIN
IF @status = '' OR @status = 'A' OR @status = 'B'
BEGIN
--Insert cancellation record into cancel table
EXEC sp_insert_cancel @order_id
--NEED TO SEND BACK STATIC (SUCCESS) MESSAGE TO ASP PAGE HERE
END
END
ELSE
--NEED TO SEND BACK STATIC (ERROR) MESSAGE TO ASP PAGE HERE
END
OUTPUTparameter in your stored procedure? Because you can useadParamOutputand return a numeric "error code" value.