ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2002, 06:56 PM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via Yahoo to fakker
closing ASP code....??

Hi,

I have created a whole site in ASP and didnt realise I had to close the ASP code...

do I really need to?
what are the implications if I dont?

eg:
I open the DB to show the records... then I do not use the

objRS.Close
set something = nothing

at the end of the page...

should I do that? If so, why?
THanks...
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #2  
Old July 19th, 2002, 07:39 PM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to Lindset Send a message via AIM to Lindset
I don't know about ASP, but PHP automatically close for example database connections
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #3  
Old July 19th, 2002, 07:42 PM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via Yahoo to fakker
hmm... well I checked in my books.. and they all close the code..
I suppose I should just do it!

The reason I ask is because after a while of testing the site on the server, it said that there was not enough space on the host to perform the operation...

I wondered if that was because I was opening multiple versions of the DB? It might put a strain on the server if loads of people are doing the same?

Cheers neway!

Reply With Quote
  #4  
Old July 20th, 2002, 08:20 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Well the ASP object model automatically nulls objects once they go out of scope, however if you're using server.creatobject maybe 5-20 times in one script, then there is a great chance that all memory may be used up, especially if you've created the COM objects and not closed the objects in that code as well...

Reply With Quote
  #5  
Old July 21st, 2002, 03:25 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 8
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Hi,

Not only is it considered good programming in ASP to explicitly Null objects but in your case when it comes to database connection it is considered wise to do.

Everytime to open a connection to a database with
Set oConn = Server.CreateObject("ADODB.Connection")
oCnn.Open strConnectionString
you open a new thread. Especially when the application receives a nice number of hits, you leave the database connection open longer than needed.
Also if your database has a limit on concurrent connections (e.g when you are using Access), you should connect in/connect out as soon as possible.
In case of recordsets I normally use the following function that makes use of the GetRows method. This function returns an array containing the recordset, or 0 if the recordset.EOF

Function fnGetRecords(sSQL)
Dim oConn, oRs
Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open sTheConnectionString

Set oRs = oConn.Execute (sSQL)

if oRs.EOF Then
fnGetRecords = 0
Else
fnGetRecords = oRs.GetRows
End If

oRs.Close
Set oRs = Nothing
oConn.Close
Set oConn = Nothing
End Function

With this function you ensure that your connection time to the databse is as low as possible. With this type of programming you can still get significant hits out of a database like Access
__________________
- Rogier Doekes

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > closing ASP code....??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek