[thelist] conserving resources - closing a recordset in ASP

Sarah Sweeney ssweeney at w3internet.com
Mon Sep 22 13:10:32 CDT 2003

I am trying to make my ASP code a little easier to write, and read, by 
creating a function to perform a query for me and return a recordset. Here 
is the function:
   function doQuery(sql)
     var rs = Server.CreateObject("ADODB.Recordset");
     return rs;
Of course, using this function means that the recordset doesn't get closed. 
So, if I were to do something like:
   var contents = doQuery('SELECT Title FROM Content');
   while (!contents.EOF)
     Response.Write(contents('Title') + '<br />');
   contents = null;
Is "contents.Close;" actually closing the original recordset, or just a 
copy? If it's only closing a copy, is there any way to get around this, 
without having to scrap my doQuery() function altogether?



More information about the thelist mailing list