Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performance

Status
Not open for further replies.

akutty

IS-IT--Management
Jul 7, 2004
31
0
0
GB
Hi All,
Some of our ASP pages are very big. These ASP pages are opening many recordsets. Not sure if they are getting closed.

Do you know of any way where we can identify the open recordsets.
for e.g
rsCredit.open
rsdebit.open


and if recordset rsdebit is not closed
display that rsdebit is still open.

or any way to close any recordset objects at the end of the asp page

regards
Anil
 
I would suggest to you use a include file in your case...something like this closerecordsets.asp which contains the following sample code

<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

then, at the bottom of all your pages that have a recordset and a connection, include this:

<!--#include file="closerecordsets.asp" -->


aslo dont forget to set your recordsets to nothing after closing them...

-DNG
 
Not sure if they are getting closed.

If you know the names of the recordsets that are opened and are not sure if they have been closed when you want to check - i.e. if you conditionally create them, then us the state property...

Code:
if rsdebit.State = 1 then
   rsdebit.close
   set rsdebit = nothing
end if

You can either do this at the end of the page via an include if you use standard recordset names across multiple pages (otherwise just do it directly in the page). However,..

I would strongly suggest that you don't wait until the end of the ASP script to close your recordset objects... as soon as you have finished with them, close them - with big scripts this can make a significant improvement on performance when stress testing, and in real life use.

To improve performance even further you may want to consider using GetRows method of the recordset object to populate an array, you can then close/destroy the recordset object immediately and just use the array. You should also destroy the array upon completion of its use within the script to save memory. But you need to check how you are using the data, GetRows isn't a fix-for-all.

Also, this thread may be useful for performance tips:
And there are several FAQs that help with performance too, do a search on "performance".

Good Luck.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
One addition to dambers post. If you are going to wait until the end of the script to check if your recordset are still open, your first statement should probaly be an Isnothing on the object rather than assuming it is still an object. Otherwise you'll get some fun and interesting errors.

That aside, I agree 100% with his advice on closing the objects and setting them to nothing as soon as you are done using them. I just wanted to point out the IsNothing check so I could feel like I have posted somehting useful in the past month :)

barcode_1.gif
 
There a much easier way to close a recordset without knowing if it has already been closed or not. Just put an "On Error Resume Next" statement before the close(s), and put an "On Error Go To 0" statement after them.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top