Solved

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

Posted on 2003-11-04
3
402 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

11 Experts available now in Live!

Get 1:1 Help Now