Solved

Saving resources by closing conn/recordsets and using 'adModeRead'

Posted on 2003-11-04
3
406 Views
Last Modified: 2009-07-29
Fairly simple asp question for the asp experts.( ihope)

I would like to code my pages to save as much resources as possible. Im using Access and ASP.  So I need to save as much as possible.

I need to know how to use the adModeRead
 in this connection.:


<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/myconnection.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_myconnection_STRING
Recordset1.Source = "SELECT * FROM calendar"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>

Also does this code close the connection AND the recordset, or is there other code that I should place at the bottom of the page?

<%
Recordset1.Close()
set recordset1 = nothing
%>


I use this on every asp page.  I hope that this opens and closes connections to free up as much resource as possible, with out have to completely re-code many pages.
Thank you in advance.

0
Comment
Question by:rockmansattic
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 175 total points
ID: 9679467
I wouldnt worry about setting a connection readonly since its only likely to be open a few seconds anyway.  You obviously use Macromedia, this is your code condensed to its smallest with a basic cursor type to allow you to go through the results.
<%
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/myconnection.asp" -->

set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_myconnection_STRING
Recordset1.Open "SELECT * FROM calendar",MM_myconnection_STRING
%>

And your closing script is correct, nothing else needed
0
 
LVL 10

Author Comment

by:rockmansattic
ID: 9679509
Thank you, and yes, I use ultradev 2004.  
I have had trouble with my host about 'temporary folder resources'.  I was told it was about the open connections, but I really dont know.  

I also have read that the readonly takes up less space.   It is possible that I may have about 300 users, probably not at once , but I dont know how it will act.

Thanks.
0
 
LVL 58

Expert Comment

by:Gary
ID: 9679577
I've never used the readonly aspect of the connection so I can't verify its usefulness.  You're also not using the connection object, you're just using the connection string so you can't even use that property in your code as it is.
But you understand that the recordset connection only exists for the time it takes for you to get the data, it doesn't persist.  You should always close your objects as soon as you have finished with them.  Tell the host to increase the temp folder allocated space
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now