PDA

View Full Version : Open connections to database crash server


dave
08-20-1999, 06:46 PM
Hi, I'm having the following problem:<BR><BR>On my site I have about about 15 different ASP files which each open a connection to the same MS Access Database. After a connection is opened in a file from 1-5 queries are executed utilizing that connection. This seems to work fine generally.<BR><BR>However, about twice a day my site crashes my ISP's server because there are hundreds of connections that were opened and never closed. I've looked through all my ASP code and can't find a place where I neglect to close a connection. Is there something else I'm missing or that I should look for?<BR><BR>I'm using commands in the following format:<BR><BR><%<BR>Set MyConn = Server.CreateObject("ADODB.Connection")<BR> MyConn.Open "DSN=bug1"<BR> Set RS = MyConn.Execute(sqlQuery1)<BR> Set TS = MyConn.Execute(sqlQuery2)<BR>%><BR><BR><%<BR> WHILE NOT RS.EOF<BR>%><BR><BR><%<BR> RS.MoveNext<BR> WEND<BR> RS.Close<BR>%><BR><BR><%<BR> TS.Close<BR> MyConn.Close<BR> %>

Alfredo Fornaso
08-23-1999, 03:18 PM
Try to set the objects to nothing after close it.<BR>here is your modified code.<BR>sorry my english ...<BR><BR><%<BR>RS.MoveNext<BR>WEND<BR>RS.Close<BR>set RS=nothing<BR>%><BR><BR><%<BR>TS.Close<BR>set TS=nothing<BR>MyConn.Close<BR>set RS=nothing<BR>%>