Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Connections to my ADODB Access DB

Status
Not open for further replies.
Feb 4, 2002
792
GB
Hi guys,

I have been playing with DBs for a while and have not had much trouble until my most recent project.

I have the following code in my code.asp file (included in my asp page):

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=littleacorns.dsn"
objConn.Open

All well and good... I get the info I need from various RS calls... and this is presented on the page as required. However, if I try to go back to the page either by refresh of closing the browser and using the exact same URL, I get the following error:

Technical Information (for support personnel)

Error Type:
Provider (0x80004005)
Unspecified error
/la2/code.asp, line 20


Browser Type:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Pantheon Ventures Limited; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)

Page:
GET /la2/littleacorns.asp

Time:
28 December 2006, 21:45:08

Line 20 is the objConn.Open bit I pasted above.

Oddly enough, if I wait a few minutes and try again, it works!! I have a feeling something is not closing properly, even thoufgh my code includes the following at the end (which is the same in ALL my objConns):

objConn.Close
Set objConn = Nothing

Any ideas what is happening? Is it to do with Session timeout? If I manually close the connection this shouldn't be a problem, right?

Will
 
Try....

objConn.Close
Set objConn = nothing

...after you've closed the last recordset you use in your script
 
Do you have any includes or any other process that may be opening a connection in the page or global file?

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Strange... I went back into this web page to "clean" it up so I could post the code, and then ran it to make sure it wasn't working... and it worked!

However, after playing with it and opening and closing Access a few times, the same problem occurred.

I reboot, and all is fine. I think, therefore (i am) it must be my Access causing a leak of some sort.

Still as a site on it's own, everything works fine. Just developing it is a pain as I have to reboot every once in a while if I use Access.

Thanks all,

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top