Re: Proper Database Connection Cleanup
- From: "Bill James" <wgjames@xxxxxxxx>
- Date: Sun, 8 Apr 2007 01:56:00 -0500
Two suggestions to add to your cleanup.
Set ObjCmd.ActiveConnection = Nothing
ObjRS.Close
Also, your statement, "This code will be used over and over", makes me wonder if you are using the same recordset variable multiple times in the same page.
--
Bill James
"Jonathan" <Jonathan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:590224D5-3D64-4C70-AD3A-51335E1357DB@xxxxxxxxxxxxxxxx
I am running IIS with classic ASP and I am having issues loading some of my.
pages. I get an error that says:
"The requested resource is in use. "
What I want to do is have a function to open the database in an include
file. This code will be used over and over so it needs to be in one spot.
Here is the code that I am using in an include file named DB.inc:
Public Sub ConnectToDB2(byref XCmd, byref YRS, byRef Conn)
'this function connects to the database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Mode = 3
Conn.Open ("DRIVER={MySQL ODBC 3.51
Driver};SERVER=localhost;DATABASE=DB;USER=admin;PASSWORD=blahblahblah;OPTION=3;")
Set XCmd= Server.CreateObject("ADODB.Command")
XCmd.ActiveConnection = Conn
Set YRS = Server.CreateObject ("ADODB.Recordset")
end Sub
In my pages, I open the database by calling ConnectToDB2 ObjCmd, ObjRS,
ObjCon At the end of the page, I clean everything up like this:
Set ObjRS = Nothing
Set ObjCmd = Nothing
ObjCon.Close
Set ObjCon = Nothing
Any ideas why I keep getting the resource in use errors? I have several
include files but the database in opened in my page. The page includes the
inc files that manipulate the data from the DB. To have only one DB
connection object, I open the DB only once in my page and clean it up at the
end.
Thanks for any ideas.
- Follow-Ups:
- Re: Proper Database Connection Cleanup
- From: Richard Mueller [MVP]
- Re: Proper Database Connection Cleanup
- Prev by Date: How does VBScript communicate with IE popup dialog box?
- Next by Date: Re: Proper Database Connection Cleanup
- Previous by thread: How does VBScript communicate with IE popup dialog box?
- Next by thread: Re: Proper Database Connection Cleanup
- Index(es):
Relevant Pages
|
Loading