title: ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed. classic ASP
body: <p>I know this is probably a dupe of another question but i really have no idea, i've searched all over and tried everything but it still seems to be giving me the same error of;</p>
  
  <blockquote>
    <p>ADODB.Recordset error '800a0e78'</p>
    
    <p>Operation is not allowed when the object is closed.</p>
  </blockquote>
  
  <p>If someone could help me with this it would be greatly appreciated, I'm using classic ASP, SQL and HTML;</p>
  
  <p>My classic ASP code is;</p>
  
  <pre class="lang-vb prettyprint-override"><code>If(Request.Form("submitBtn"))&lt;&gt;""Then
    'Initialise the db connection
    Set objDBConn = Server.CreateObject("ADODB.Connection")
    objDBConn.Open "Provider=sqloledb;Data Source=OLIVERBEELEY;Initial Catalog=HolidayEmployeeBooker;User ID=HBA;Password=HBA;"
  
    'Initialise the command object
    Set objDBCommand = Server.CreateObject("ADODB.Command")
  
    objDBCommand.ActiveConnection = objDBConn
    objDBCommand.CommandText = "spNewHoliday"
    objDBCommand.CommandType = adCmdStoredProc
  
    'Set the parameters             
    objDBCommand.Parameters.Append objDBCommand.CreateParameter("@StartDate", adDate, adParamInput,200)
    objDBCommand.Parameters.Append objDBCommand.CreateParameter("@EndDate", adDate, adParamInput,200)
    objDBCommand.Parameters.Append objDBCommand.CreateParameter("@EmployeeID", adVarChar, adParamInput,200)            
    objDBCommand.Parameters.Append objDBCommand.CreateParameter("@Reason", adVarChar, adParamInput,200)
  
    objDBCommand("@StartDate") = Request.Form("from")
    objDBCommand("@EndDate") = Request.Form("to")
    objDBCommand("@EmployeeID") = Session("UserID")
    objDBCommand("@Reason") = Request.Form("comments")
  
    'Initialise the Recordset
    Set objDBRS = Server.CreateObject("ADODB.RecordSet")
  
    'Execute 
    objDBRS.open objDBCommand,,adOpenForwardOnly
  
    if not objDBRS.EOF then
      Session("BookingValid") = objDBRS(0)
    end if
  
    if Session("BookingValid") = "ErrorBookingHoliday" then
       response.Write("&lt;SCRIPT LANGUAGE=""JavaScript""&gt;alert(""Holiday CANNOT be booked."");&lt;/SCRIPT&gt;")
    end if
    if Session("BookingValid") = "ErrorBookingHoliday" then
       response.Write("&lt;SCRIPT LANGUAGE=""JavaScript""&gt;alert(""Holiday has been requested."");&lt;/SCRIPT&gt;")
    end if
  
    'Close and Destroy Objects - Start*******************************************************
    Set objDBCommand=nothing
    objDBConn.Close
    Set objDBConn=nothing
    'Close and Destroy Objects - End*********************************************************
  
    response.redirect("newbooking.asp")
  
  end if 
  
  
  %&gt;
  </code></pre>
  
  <p>My Stored procedure its calling are;</p>
  
  <pre><code>PROCEDURE [dbo].[spNewHoliday]
  (
  @StartDate DATE,
  @EndDate DATE,
  @EmployeeID INT,
  @Reason NVARCHAR (45)
  )
  
  
  AS
  SET NOCOUNT ON
  BEGIN
  
  
  
  IF NOT EXISTS ( SELECT 1 
                  FROM Holidays
                  WHERE @StartDate = StartDate
                  AND @EndDate = EndDate
                  AND @EmployeeID = EmployeeID)
  
                  BEGIN
                  DECLARE @Validation INT
                      EXEC spBusinessRuleValidation @StartDate, @EndDate, @EmployeeID, @Validation OUTPUT
  
  
                      IF @Validation = 0
                          BEGIN
                              DECLARE @DaysOff AS INT
                              SELECT @DaysOff = (DATEDIFF(Day,@StartDate,@EndDate) +1)
  
                              UPDATE Employees
                              SET AnnualDaysHolidayAllowance = AnnualDaysHolidayAllowance - @DaysOff
                              WHERE @EmployeeID = Employees.ID                
  
                              INSERT INTO Holidays(EmployeeID, StartDate, EndDate, Duration, Status, Reason)
                              VALUES(@EmployeeID, @StartDate, @EndDate, @DaysOff,'Pending', @Reason)
  
                              SELECT Employees.AnnualDaysHolidayAllowance AS Daysleft FROM Employees WHERE @EmployeeID = Employees.ID
                          END
                          SET NOCOUNT ON
                      IF @Validation = 1
                          BEGIN
                              SELECT 'ErrorBookingHoliday' AS FailedBooking
                          END
                  END
  
  END
  </code></pre>
  
  <p>And the stored procedure that, that procedure is calling is;</p>
  
  <pre><code>PROCEDURE [dbo].[spBusinessRuleValidation]
  (
  @StartDate DATE,
  @EndDate DATE,
  @EmployeeID INT,
  @Validation INT output
  )
  
  AS
  SET NOCOUNT ON
      BEGIN
          DECLARE @JobRoleID INT
          DECLARE @MaxJobTypeAllowedOff INT       
          DECLARE @MaxEmployeesAllowedOff INT
          DECLARE @DateCount INT
          DECLARE @SameJobRoleOff INT
          DECLARE @DateCheck DATE
  
          SET @JobRoleID = (SELECT JobRoleID FROM Employees WHERE @EmployeeID = Employees.ID)
          SET @MaxJobTypeAllowedOff = (SELECT MaxEmployeesAllowedOff FROM JobRole WHERE @JobRoleID = JobRole.ID)
          SET @MaxEmployeesAllowedOff = 20
          SET @DateCheck = @StartDate
          SET @EndDate = DATEADD(DAY, 1, @EndDate)
          SET @Validation = '0'
  
          WHILE (@DateCheck &lt;&gt; @EndDate)
          BEGIN
              SET @DateCount = (SELECT COUNT (*) FROM Holidays WHERE Holidays.Startdate &gt;= @DateCheck AND Holidays.EndDate &lt;= @EndDate )
              IF @DateCount &gt; @MaxEmployeesAllowedOff
                  BEGIN
                      SET @Validation = '1'
                      BREAK
                  END
  
              SET @SameJobRoleOff = (SELECT COUNT (*) JobRoleID
              FROM Employees
              RIGHT JOIN Holidays
              ON Employees.ID = Holidays.EmployeeID
              WHERE Employees.ID = @EmployeeID AND Holidays.Startdate &gt;= @DateCheck AND Holidays.EndDate &lt;= @EndDate AND Holidays.Status &lt;&gt; 'Declined')
  
              IF @SameJobRoleOff &gt; @MaxJobTypeAllowedOff
                  BEGIN
                      SET @Validation = '1'
                      BREAK
                  END
  
              SET @DateCheck = DATEADD(DAY, 1, @DateCheck)
          END
      END
  </code></pre>
  
  <p>I am very new to SQL and ASP (about 3-4 months of experience) and need some help with this problem, any help would be appreciated even if its just to do with code that isnt the cause of my error! Thanks! OH this is the code where it goes wrong!</p>
  
  
  
  <pre><code>if not objDBRS.EOF then
    Session("BookingValid") = objDBRS(0)
  end if
  </code></pre>