Author |
Topic  |
Deleted
deleted
    
4116 Posts |
Posted - 09 February 2003 : 10:11:28
|
Suppose you have a connection and a record set object created. You check a condition and then stop execution using response.redirect or response.end.
Is it safe to handle such cases in this way? What happens to the open resources?
Please think of all combinations (database & web server) Snitz is supporting...
|
Stop the WAR! |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
|
Deleted
deleted
    
4116 Posts |
Posted - 09 February 2003 : 11:50:05
|
So do I, at least I try to. As far as I know IIS 5 can salvage the remaining resources but this is not the case for IIS 4. I don't know about others.
There are some places in the base code where they are left open. If they can result in a leak, repeated call to this kind of behaviour can cause problems on the server.
|
Stop the WAR! |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 February 2003 : 15:46:51
|
I use a custom function to access DB and close the recordset and connection within the function. The Thumb rule is "Open Late, Close Early". |
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 09 February 2003 : 16:04:17
|
what does that do to performance though GB? Let's say you open multiple recordsets on one page, doesn't that open and close the db connection each time? |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 February 2003 : 17:11:12
|
I store the required information in variables or arrays. The site I am currently working on has html and asp code completely separate. I store the information to be displayed in constants or variables or arrays. The html page uses the variables or constants populated via asp code and is displayed to the user. It is not that hard once you get going. I can redisgn the presentation any time and any way. |
Edited by - GauravBhabu on 09 February 2003 17:16:52 |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 09 February 2003 : 17:16:29
|
quote: Originally posted by GauravBhabu
I use a custom function to access DB and close the recordset and connection within the function. The Thumb rule is "Open Late, Close Early".
Ditto. I pass the connection string and sql string to the function and get back an array from getrows. The db connection is opened and closed within the function (actually a vbs class module).
Nikkol, nearly all current IIS servers use connection pooling behind the scenes which reuses open connections if there is another call within a certain time frame, so performance is enhanced all around if you open and close right away.
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 February 2003 : 17:26:33
|
I also have a library to build the connection strings depending on the database and get information from DB. Depending on the requirements It returns Records either using Get Rows or as Recordset. I intend to add XML options as well. |
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 February 2003 : 17:30:06
|
quote: Originally posted by Nikkol
So, Doug, if you open then close and the open and close again, this is essentially the same as just opening and closing once?
It is like opening your locker take what you need close it do whatever you want to do with the contents and if you need something more open your locker again, take what you need and close it. You do not want to leave your locker open, in case you get too busy somewhere else and the locker reemains open and... |
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 09 February 2003 : 17:50:09
|
I get the idea. Just was wondering the efficiency of opening db connection ... opening and closing multiple recordsets ... closing db connection VERSUS open db conn, open recordset, close recordset, close db conn multiple times. I use GetRows almost exclusively when I get recordsets, but usually i only open one connection to db. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 09 February 2003 : 18:23:51
|
Never looked in depth but I believe opening and closing connections and or recordsets consumes lesser resources then leaving the connections and recordsets open.
Think of Electric Power. The line connection is always there but the electricity is consumed only when you turn on the lights or electrical appliances. |
 |
|
Deleted
deleted
    
4116 Posts |
Posted - 09 February 2003 : 18:49:54
|
Well, I know all these and have similar libraries for my own work, but mostly related to IIS 5, Access & SQL DB...
But wrt our work here with the forum, we don't have such mechanisms granted and I don't want to redesign everything before v4f is out.
Snitz is meant to be compatible with web servers other than IIS 5. My main emphasis in the original question is those environments that I never examined (MySQL, Sun systems, other possible *nix systems).
|
Stop the WAR! |
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 09 February 2003 : 19:04:43
|
I'm not talking about leaving them open ... this is what I mean ...
open db open recordset1 close recordset1 open recordset2 close recordset2 close db
versus
open db open recordset1 close recordset1 close db open db open recordset2 close recordset2 close db |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
HuwR
Forum Admin
    
United Kingdom
20600 Posts |
Posted - 09 February 2003 : 19:05:06
|
quote: Originally posted by GauravBhabu
quote: Originally posted by Nikkol
So, Doug, if you open then close and the open and close again, this is essentially the same as just opening and closing once?
It is like opening your locker take what you need close it do whatever you want to do with the contents and if you need something more open your locker again, take what you need and close it. You do not want to leave your locker open, in case you get too busy somewhere else and the locker reemains open and...
Mmm, not a particularly good analogy Doug, since it implies that if you leave it open something might happen to its contents, which is not correct. It is more like a room with many doors , but while you hold a door open nobody else can pass through it, closing it quickly allows someone else to use the door rather than have to wait or open find another door |
 |
|
Topic  |
|