| Author |  Topic  |  | 
              
                | ngaisteve1Junior Member
 
   
 
                Malaysia241 Posts
 | 
                    
                      |  Posted - 26 August 2003 :  23:25:53   
 |  
                      | what do you think of my code below? Is it fine for me to close the connection and recordset object this way or before response.redirect? Or after response.redirect, it will still close them? 
 if not rs.eof then
 response.redirect "rate_add_form.asp"
 else
 response.redirect "rate_login.asp?errormesg=Invalid user id or password. Try again."
 end if
 
 conn.close
 set conn = Nothing
 rs.close
 set rs = nothing
 |  | 
              
                | jfitzJunior Member
 
   
 
                USA345 Posts
 | 
                    
                      |  Posted - 26 August 2003 :  23:28:53   
 |  
                      | I don't know if it really matters, but I think I would close the record set first, and then close the connection.  Theoretically, the recordset is using the connection, and after the connection disappears, you might have a problem closing the record set.  Like I said, I don't really know if it makes a difference, but I would always code it that way - in some other environments it probably will make a big difference. |  
                      | --Jördan
 It's a wasted day if  you don't spend at least part of it flying upside down.
 |  
                      |  |  | 
              
                | HamlinAdvanced Member
 
      
 
                United Kingdom2386 Posts
 | 
                    
                      |  Posted - 27 August 2003 :  03:23:51   
 |  
                      | I always put it before the redirect, I was under the impression that nothing under the redirect gets executed, as its been redirected to the new page  |  
                      |  |  | 
              
                | OneWayMuleDev. Team Member & Support Moderator
 
      
 
                Austria4969 Posts
 |  | 
              
                | D3monSenior Member
 
     
 
                United Kingdom1685 Posts
 | 
                    
                      |  Posted - 27 August 2003 :  04:26:09     
 |  
                      | Why not set the result to a varibale then close the RS and DB connectioin before the if? blnResult = rs.eof
rs.close
set rs = nothing
conn.close
set conn = Nothing
if not blnResult then	
        response.redirect "rate_add_form.asp"
else
        response.redirect "rate_login.asp?errormesg=Invalid user id or password. Try again."
end if |  
                      | 
  Snitz 'Speedball' :  Site Integration Mod :  Friendly Registration Mod
 "In war, the victorious strategist only seeks battle after the victory has been won"
 |  
                      | Edited by - D3mon on 27 August 2003  04:27:16
 |  
                      |  |  | 
              
                | ngaisteve1Junior Member
 
   
 
                Malaysia241 Posts
 | 
                    
                      |  Posted - 27 August 2003 :  04:37:57   
 |  
                      | ok. Thanks. |  
                      |  |  | 
              
                | redbrad0Advanced Member
 
      
 
                USA3725 Posts
 |  | 
              
                | GremlinGeneral Help Moderator
 
      
 
                New Zealand7528 Posts
 | 
                    
                      |  Posted - 28 August 2003 :  06:49:21     
 |  
                      | The connection should close after a timeout on all versions of IIS afaik, but yes its better to close it explicitly rather than rely on the OS doing it for you. |  
                      | Kiwihosting.Net - The Forum Hosting Specialists
 
 |  
                      |  |  | 
              
                |  |  Topic  |  |