Closing Connections

Results 1 to 2 of 2

Thread: Closing Connections

  1. #1
    Join Date
    Dec 1969

    Default Closing Connections

    I have an ASP application that connects to a sql sever database. When I run the application the first time, it goes smoothly. But then if I try to run it again (or any of my other asp applications) it just hangs there for hours. <BR><BR>My network administrator mentioned that if I didn&#039;t close my connection properly, it might cause subsequent runs to hang. Is this true? If so, what&#039;s the proper way to close connections. If not, what else could be causing my application to hang?<BR><BR>Here&#039;s is the code I use to open and close my connections:<BR><BR>Set db = New AdoHelper<BR>Set cmd = Server.CreateObject("adodb.Command")<BR>Set ReferObject = New ReferDB<BR>cmd.ActiveConnection = db.GetConnectionString()<BR>cmd.CommandType = adCmdStoredProc<BR>cmd.Prepared = True<BR>db.ClearParameters(cmd)<BR><BR><BR>Closing :<BR>Set db = Nothing<BR>Set cmd.ActiveConnection = Nothing<BR>Set cmd = Nothing<BR><BR><BR>Function ClearParameters(ByRef cmd)<BR>Dim i<BR>On Error Resume Next<BR>If cmd.Paramters.Count &#060; 1 Then Exit Function<BR><BR>For i=0 To cmd.Parameters.Count<BR> cmd.Parameters.Delete 0<BR>Next<BR><BR>Err.Clear<BR>End Function<BR><BR>Thanks in advance<BR>

  2. #2
    Join Date
    Dec 1969

    Default not really advanced, but still.......

    .... yes, in some cases, anecdotal evidence says that not closing connections can cause the behaviour you see. basically you should ALWAYS, without exception, close and clean up connections after use.<BR><BR>Of course, this looks like VB rather than VBScript, or you&#039;re using classes which aren&#039;t shown - perhaps the reason lies somewhere else, but I couldn&#039;t say about that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts