I want to delete an item from a database based on a button that is clicked on a webpage. A user can choose to delete items from their account.
I pass the account number and item number through to a stored procedure. The stored procedure deletes the item if it exists, and returns either 1 for success or 0 if there was an error.
My problem is that the ASP page when submitted constantly returns an error:
ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed.
If I submit the stored procedure directly, I can delete the item and a record is created where status is 1. If it is not deleted, record has status as 0.
Therefore, there should always be a recordset created that has status either 1 or 0.
Here is the stored procedure:
CREATE PROCEDURE dbo.SAVED_ITEM_DELETE
@AccountID int,
@Item int
AS
BEGIN
DECLARE @Status INT
SET @Status = 1
IF EXISTS(SELECT AccountID FROM Accounts_Items
WHERE AccountID = @AccountID AND Item = @Item)
BEGIN TRY
DELETE Account_Items
WHERE AccountID = @AccountID AND Item = @Item
END TRY
BEGIN CATCH
SET @status = 0
END CATCH
SELECT @Status AS Status
END
And here is the ASP that calls the procedure
dim de
Set de = Server.CreateObject("ADODB.recordset")
de.open "SAVED_ITEM_DELETE 1,49", connect,2
IF not de.EOF THEN
IF de("Status") = 1 THEN
response.write request("delete") & " - deleted"
ELSE
response.write request("delete") & " - not deleted"
END IF
END IF
I am getting the error on the line:
IF NOT de.EOF THEN
Please, please, please help! I just cannot fathom why ASP doesn't see a recordset with a field called Status that's either 1 or 0.
@status
from a variable to a parameter and add the keywordoutput
, I really can't remember, though, how to get it back toadoddbo.Command
. It's been over a decade since I last used asp3. – Zohar Peled