| Author |
Topic Search Topic Options
|
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
Topic: Check if RS and Conn are open Posted: 02 March 2005 at 11:48am |
|
How can one check whether a recordset and connection was left open, so it can be closed dynamically in the footer file. Is there any way to know this?
|
|
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 March 2005 at 12:05pm |
Well I don't know if that's gonna work in asp, but may be worth a try. Thus in vb.net you can do something like
Dim con As New OleDb.OleDbConnection .......... If con.State = ConnectionState.Open Then con.Close() End If
Edited by michael - 02 March 2005 at 12:06pm
|
|
|
 |
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 March 2005 at 12:16pm |
|
Nope, that's not available in ASP, thanks anyway, I wish it was, the thing is that I know all conns and RSs should be closed as soon as no longer needed, however, I would like to cerify myself that if it wasn't closed it would be in the footer, kind of better late then never.
Also, if a conn and RS is left open what could be the problems?
|
|
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 March 2005 at 2:50pm |
|
Try
If IsObject(Conn)=True then
Conn.Close
set Conn=Nothing
end if
|
|
|
 |
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 March 2005 at 11:25am |
|
Thanks ljamal, but it is not working, it errors out with the obvious 'Object required' on pages that have the Conn closed, IsEmpty and IsNull also don't work.
Jezzz, don't tell me there's no way to know if a Conn is open or not in ASP?
Anyone?
|
|
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 March 2005 at 12:21pm |
|
If you use IsNull you know you need to change the evaluation to False, right?
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 March 2005 at 12:40pm |
|
It's probably more efficient if you actually go back in your code and
re-write it so that you always close them when you know they are open,
I had a similar problem before, it's probably only going to get worse
and more complicated than it needs to be.
|
 |
theSCIENTIST
Senior Member
Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 March 2005 at 2:39pm |
I realised that, nevertheless, I just added this to my footer:
<%
'/* Last chance to close objetcs */
On Error Resume Next
'/* Debug info */
'If Err.Number = 0 Then Response.Write("rsCommon state: " & rsCommon.State)
'If Err.Number = 0 Then Response.Write("<BR>")
'If Err.Number = 0 Then Response.Write("adoCon state: " & adoCon.State)
'/* Close the damn thing */
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
%> |
The (On Error Resume Next) allows for it to not produce errors in case conns are closed.
|
|
|
 |