Error When Closing Recordset Objects

Results 1 to 2 of 2

Thread: Error When Closing Recordset Objects

  1. #1
    Join Date
    Dec 1969

    Default Error When Closing Recordset Objects

    I usually create Recordset sets using the following script:<BR><BR>Line 010: Set rsSample = ConnectionObject.Execute(SQL_Statement)<BR><BR>Onc e created, I usually run through the recordset, like:<BR><BR>Line 011: While Not rsSample.EOF<BR>Line 012: Response.Write rsSample("Field1") & "&lt;br&#062;"<BR>Line 013: rsSample.MoveNext<BR>Line 014: Wend<BR><BR>I follow by Closing the Recordset Object, like:<BR><BR>Line 015: rsSample.Close<BR>Line 016: Set rsSample = NOTHING<BR><BR>PROBLEM: Occassionally (not every time), I get the following Error Message:<BR><BR>Microsoft VBScript runtime error &#039;800a01a8&#039; <BR>Object required: &#039;&#039; <BR>/MyASPPage.asp, line 015<BR><BR>It seems that my Recordset Object (rsSample) is "Closing Itself". Whenever, I attempt to ".Close" the Recordset, I get the forementioned error.<BR><BR>By eliminating the "rsSample.Close" line (Line 015), my script works perfectly.<BR><BR>Q: What gives? Why can&#039;t I Close my Recordset Object?<BR><BR>My gut feeling tells me that it has something to do with the way I create the Recordset. My guess is that I "implicitly" create the Recordset Object using the "Connection_object.Execute(SQL)" method, rather than with the formal "Server.CreateObject("ADODB.recordset") method. My method creates a recordset that uses a Foreward Only curser. Could it be that when my recordset reached EOF, the recordset "implicitly" closes itself? Hence, when I attempt to Close the Object, an error tells me that "an object is required" (i.e. the recordset is already Closed).<BR><BR>Thanks!<BR>

  2. #2
    Join Date
    Dec 1969

    Default What was the SQL used?

    If you use an INSERT, UPDATE, or DELETE sql statement, then no recordset is created. You should *not* do <BR> SET RS = conn.Execute("INSERT ...")<BR>instead, just do<BR> conn.Execute("INSERT...")<BR><BR>(applies to UPDATE and DELETE, of course, as well)<BR><BR>If you really did have this happen when doing a SELECT query, then I want to see the full code.<BR><BR>

Posting Permissions

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