Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Check if RS and Conn are open
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Check if RS and Conn are open

 Post Reply Post Reply Page  12>
Author
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 2:50pm
Try

If IsObject(Conn)=True then
   Conn.Close
   set Conn=Nothing
end if
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2005 at 12:21pm
If you use IsNull you know you need to change the evaluation to False, right?
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.