Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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/…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

705 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