|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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... |
|
#2
|
|||
|
|||
|
I don't know about ASP, but PHP automatically close for example database connections
__________________
Best Regards, Håvard Lindset |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
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...
|
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > closing ASP code....?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|