Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-04
3
Medium Priority
?
416 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 700 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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