Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2006, 09:23 PM
Authorized User
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Speeding up processing time on ASP file

I have an ASP file that takes about 6 seconds from telling the browser to open it, to the page appearing on the screen. Its a big table that is generated from data from 2 seperate access tables. My code isn't very long, but I do realize I am looping it 73 times, one loop for each row in the table, so I expect it to be slow, but I was just wondering if there was anything I can do to it in order to speed things up a bit.

Thanks!

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <style>
    td { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    body { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    </style>
    <title>Breaks Page</title>
</head>

<body>
    <%
    Function pad0(n)
    If n >= 10 then
   pad0 = Cstr(n)
    else
   pad0 = "0" & Cstr(n)
    end if
    end function
    ' Declaring variables
    Dim form_id, data_source, con, rs1, sqlrecord, count, m, h, sqlrecord2, rs2, status, stime
     form_id = CInt(Request.Form("id"))
     data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                 Server.MapPath("breaks.mdb")
     %><table border="1" id="table1" width="661" cellspacing="0" cellpadding="0">
          <p align="left">Current Time:<%=time()%></p>
        <p align="left"><a href="../feedback/feedback.html">
        Questions, Comments, Suggestions?</a></p>
        <p align="center"><b><span style="font-size: 10pt">Breaks</span></b></p>
     <tr><td>Time<td>Status</td><td width="63">Legend:</td><td bgcolor="#FF9933">Short Break</td><td bgcolor="#3399FF">Break</td></td><td bgcolor="#FFFF00">Lunch</td></tr><%
    count=0
    m = 45
    h = 7

    For count=1 to 73

    m = m + 15
    if m >= 60 then
       m = m - 60
       h = h + 1
    end if
    if h >= 24 then
    h = 0
    m = 0
    End If

    sTime = Cstr(h) & ":" & pad0(m)


     sqlrecord= "Select * FROM users WHERE slot=" & count & ";"
     sqlrecord2= "Select * FROM slots WHERE slot=" & count & " ;"

    ' Creating Recordset Object and opening the database
       Set rs1 = Server.CreateObject("ADODB.Recordset")
       Set rs2 = Server.CreateObject("ADODB.Recordset")
       rs1.Open sqlrecord, data_source
       rs2.Open sqlrecord2, data_source
           %>
        <tr>
            <td height="36"><b><%response.write(sTime)%></b></td>
            <%If rs2("status")="open" then%>
            <td bgcolor="#66FF33">
            <p align="center"><b>Open</b></td>
            <%Else If rs2("status")="closed" then%>
            <td bgcolor="#FF3300">
            <p align="center"><b>Closed</b></td>
            <%End If End If%>
            <%While Not rs1.EOF
            If rs1("kind")="break" then %>
            <td width="120" bgcolor="#3399FF"><b><%=rs1("user")%></b></td>
            <%Else If rs1("kind")="lunch" then%>
            <td width="190" bgcolor="#FFFF00"><b><%=rs1("user")%></b></td>
            <%Else%>
            <td width="143" bgcolor="#FF9933"><b><%=rs1("user")%></b></td>
            <%End If End If
             rs1.MoveNext
            Wend
            If rs2("status")="open" then%>

            <td width="54" height="36" valign="top"><form action="request.asp" method="post">
            <input type="hidden" name="slot" value="<%=rs2("slot")%>">
            <button name="B3" style="padding:-4px; width: 52px; height: 18px; font-size:8pt" type="submit">Request</button></form></td></form>
<%End If
   ' Done. Now close the Recordset
   rs1.Close
   rs2.Close
   Set rs1 = Nothing
   Set rs2 = Nothing%>
   </tr>
   <%
   Next %>
      </tr>
</div>
</body>
</html>

 
Old April 12th, 2006, 09:57 PM
Authorized User
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I partially answered my own question already. I got the Set rs1 = Server.CreateObject("ADODB.Recordset") and Set rs1 = Nothing commands outside of the loop and its running at about 2.5 seconds now.

 
Old April 14th, 2006, 04:51 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hei sswingle!

What next does the <%next%>, line five from the bottom, display? Does not the rs1.MoveNext see to that?

Med vennlig hilsen
grstad

PS. All questions are good questions!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Saxon - run-time error during processing entity ROCXY XSLT 1 June 29th, 2007 04:39 AM
Speeding up DB search, how? rtr1900 Classic ASP Databases 3 December 18th, 2006 09:04 AM
Redirecting while keeping the file processing rungss Pro PHP 2 February 25th, 2006 12:52 AM
Processing text file from Oracle in Excel Macsinging Excel VBA 2 November 23rd, 2005 03:53 PM
How to reduce the processing time for this prob? changeable Excel VBA 0 October 27th, 2004 04:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.