Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Code taking long to run:

Reply
Thread Tools

Code taking long to run:

 
 
Brent
Guest
Posts: n/a
 
      02-02-2004
Hello all.. I have a recordset that has 12 records in it, and about 25 columns. Unfortunately, I have to write the records out as columns in an ASP page, and the columns as rows. So, what I have done is a Do Until myRS.EOF and write all the records in <td></td> tags. I then do a myRS.MoveFirst before going to the next line. So basically, I am writing until EOF and moving first about 25 times. I have 3 webpages that do this, and 2 of them work great. This code runs in a couple seconds on the other pages. However I have one page that is identical in code, just using a different recordset, that is taking about 7 seconds to write per line. The other 2 pages are taking less than a second per line. Has anyone seen anything like this before? Anyone have any suggestions? Below is an example of a loop that is taking so long to run. Thanks for your help

do until myRS.EO
Response.Write("<td bgcolor=#eeeeee>" & myRS("OutstandingInCompliance") & "</td>" & vbcrlf
iTotal = iTotal + cdbl(myRS("OutstandingInCompliance")
myRS.MoveNex
loo

 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      02-02-2004
"Brent" <> wrote in message
news:8437352B-C64A-4698-98B1-...
> Hello all.. I have a recordset that has 12 records in it, and about 25

columns. Unfortunately, I have to write the records out as columns in an
ASP page, and the columns as rows. So, what I have done is a Do Until
myRS.EOF and write all the records in <td></td> tags. I then do a
myRS.MoveFirst before going to the next line. So basically, I am writing
until EOF and moving first about 25 times. I have 3 webpages that do
this, and 2 of them work great. This code runs in a couple seconds on
the other pages. However I have one page that is identical in code, just
using a different recordset, that is taking about 7 seconds to write per
line. The other 2 pages are taking less than a second per line. Has
anyone seen anything like this before? Anyone have any suggestions?
Below is an example of a loop that is taking so long to run. Thanks for
your help.
>
> do until myRS.EOF
> Response.Write("<td bgcolor=#eeeeee>" &

myRS("OutstandingInCompliance") & "</td>" & vbcrlf)
> iTotal = iTotal + cdbl(myRS("OutstandingInCompliance"))
> myRS.MoveNext
> loop


Using the Recordset.GetRows method. You should see some substantial
improvements in the performance of your page.

<%
Dim cn,rs,arr
Set cn = CreateObject("ADODB.Connection")
cn.Open "<DSNLess OLEDB Connection String>"
Set rs = cn.Execute("<SELECT statement>")
If Not rs.EOF Then arr = rs.GetRows()
rs.Close : Set rs = Nothing
cn.Close : Set cn = Nothing

If IsArray(arr) Then
Dim i,iMax,j,jMax
iMax = UBound(arr,1)
jMax = UBound(arr,2)
Response.Write "<table>"
For i = 0 To iMax
Response.Write "<tr>"
For j = 0 To jMax
Response.Write "<td>"
Response.Write Server.HTMLEncode(arr(i,j))
Response.Write "</td>"
Next
Response.Write "</tr>"
Next
Response.Write "</table>"
Else
Response.Write "No Records"
End If
%>

Here's an article on the pros and cons of various methods for display
recordset data:
http://aspfaq.com/2467

HTH
-Chris Hohmann


 
Reply With Quote
 
 
 
 
Brent
Guest
Posts: n/a
 
      02-02-2004
Ok, so I've tried running this page one of two ways. The first is using a stored procedure (that takes an sql string and just runs it). The second is just having ASP open the recordset without a stored procedure. Using a stored procedure takes about 7 seconds to write each line (and there are about 25 lines to write). Not using a stored procedure takes < 1 second to write every line. Just an FYI.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to ‘(const __gnu_cxx::hash<long long int>) (const long long int&)’ veryhotsausage C++ 1 07-04-2008 05:41 PM
Use of Long and Long Long Bart C C Programming 27 01-15-2008 05:27 AM
long long and long Mathieu Dutour C Programming 4 07-24-2007 11:15 AM
unsigned long long int to long double Daniel Rudy C Programming 5 09-20-2005 02:37 AM
Assigning unsigned long to unsigned long long George Marsaglia C Programming 1 07-08-2003 05:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57