Solved

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

Posted on 2003-11-04
3
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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