Forum Moderators: open

Message Too Old, No Replies

Access Database Connections

Looking for an easy way to ensure close

         

webworker us

1:27 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Is there an easy way to ensure that all connections are closed or at least print out which are not closing?

I ask becuase I am trying to clean my predecessor's code to move away from IIS (we can't afford the server version to get unlimited connections) and he never closed his database connections (IIS does it for you).

Any hints would be great,

Casey

Easy_Coder

3:39 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Go to this thread and look at the code I put in my second post:
[webmasterworld.com...]

webworker us

3:49 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



I used that code on all of my pages (thank you for it). However, I am still getting the database problem. The code you gave said I had all of them closed, so I assume I did it correctly. I am still looking for the connection that is killing me however.

Thanks,

Casey

conn.close
set conn = nothing

is how I would close

Easy_Coder

6:22 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



webworker, you might be able to gleen the activity from perfmon while testing the pages on the site. You'll need to add some Sql Server Counters.

Do you know where that's at?

webworker us

6:33 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



I do not. I'm fairly new to ASP, and have done ok so far, but am far from being "good". If you could give me a few details I would be very greatful.

Casey

webworker us

12:55 am on Jul 21, 2005 (gmt 0)

10+ Year Member



I believe I may have found a source of at least one problem. When I connect to databases I call a function to do the connection. (Included Below). However, it doesn't kill the conn created and I can't do that without not connecting to the database. Any suggestions?

Casey


<%Dim strconn, conn
Function DBaseAction(SQLAdd, DataBaseName)
strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
strconn=strconn & "c:\inetpub\db\" & DataBaseName & ";"
set conn=server.createobject("adodb.connection")
conn.open strconn
set DBaseAction= conn.execute(SQLAdd)
End Function %>

mrMister

11:32 am on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Write another function that closes the connection and make sure you call it after you've finished using the database.

I've never seen a solution that is much more elegant than that.

Easy_Coder

9:32 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Casey -

Start --> AdminTools --> Performance

You'll need to add some SQL Server Counters so click the '+' icon that's located on top of the performance grid, locate the SQL Server Objects you want to trace and then choose the counters.

Once you have that all set, start pounding away at your site (a crawler is good for this) and keep an eye on the perfmon.

webworker us

2:17 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



Awesome, thanks. I have closed all the connections now and nothing seems to be leaking.

Casey

Easy_Coder

3:09 am on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Squashin Bugz!