Previous Next

Thread: SQL Server connection

Last post 01-10-2008 11:10 PM by tolgs. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 01-10-2008, 8:30 PM

    • tolgs
    • Top 500 Contributor
    • Joined on 01-07-2008, 11:35 AM
    • Posts 9
    • tolgs

    SQL Server connection

    We are using a dedicated Windows 2003 machine running IIS 6.0 and SQL Server 2005 (on the same machine). Our code is Classic ASP and recently our server became unresponsive during busy hours where only about 50 requests would execute (with long delay) and the rest would time out. For the site visitors the experience is a hung service with no response.

     We want to make sure that there is no memory leak driven by our code and we've checked line by line to make sure that we are closing all connections and destroying objects. However, we also would like to validate the method we connect to the SQL database and would like the help of the community here. Below is the code we are using to connect and would appreciate if someone can skim over it and tell us we we should be doing something differently: 

    <%
     Function glpCloseRst(objRst)
      If IsObject(objRst) Then
       If objRst.State = 1 Then
        objRst.Close
        Set objRst = Nothing
       End If
      End If
     End Function

     Function glpCloseDBConn (objDBConn)
      If IsObject(objDBConn) Then
       If objDBConn.State = 1 Then
        objDBConn.Close
        Set objDBConn = Nothing
       End If
      End If
     End Function
    %>

    <%
    ConnectionStrSQL = "Driver={SQL Native Client};Server=555.55.555.55;Database=dbname;Uid=username;Pwd=password;"
    set connSQL = CreateObject("ADODB.Connection")
    connSQL.open ConnectionStrSQL
    %>

    <%

    Dim allSQX
    allSQLX = "SELECT * FROM TABLE WHERE id='something';" 

    Dim allRsX
    Set allRsX = Server.CreateObject("ADODB.Recordset")
    allRsX.Open allSQLX, connSQL, 3, 3

    DO UNTIL allRsX.eof

      ...somestuff...

    allRsX.movenext
    LOOP

    glpCloseRst(allRsX)
    glpCloseDBConn(connSQL)
    %>

    many thanks

  • 01-10-2008, 10:18 PM In reply to

    Re: SQL Server connection

    In your connection string, I would put Server.CreateObject.  Besides that, it looks correct.  Are you seeing a lot of open connections on your database server?  Classic ASP code will keep the connection open, I would run sql profiler to see if you can find a sql issue.  Also, you can look in the iis logs and query for the 'time-taken' field, this can give you an idea what pages are taking a long time.

    You can use log parser, there is a sample query to extract from the logs.

    select -i:iisw3c "logparser select Top 25 cs-uri-stem, time-taken from <somesite.com> where cs-uri-stem like '%asp%' order by time-taken desc" -o:csv

    go to www.logparser.com

     

    Steve Schofield
    Windows Server MVP - IIS
    MCTS - Windows Hosting

    http://weblogs.asp.net/steveschofield
    http://www.iislogs.com
    http://www.orcsweb.com/
    Managed Hosting Solutions
    #1 in Service and Support
  • 01-10-2008, 11:10 PM In reply to

    • tolgs
    • Top 500 Contributor
    • Joined on 01-07-2008, 11:35 AM
    • Posts 9
    • tolgs

    Re: SQL Server connection

    You mean use

    set connSQL = Server.CreateObject("ADODB.Connection")

    instead of

    set connSQL = CreateObject("ADODB.Connection")   ? - will do that

    already looked at the iis logs for the time taken field and actually all of the pages are taking over 2 minutes (and they eventually time out). unfortunately can't isolate the problem to a single page.

    at this point we are looking for an expert to go over our IIS DebugDiag Hang Analysis Reports. can you recommend a resource to send these reports for a review?

Page 1 of 1 (3 items)
Page view counter