If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > What's wrong with this? Slow response from ASP Page

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-04, 11:16
axapta axapta is offline
Registered User
 
Join Date: Apr 2004
Posts: 47
What's wrong with this? Slow response from ASP Page

Hi All,

I have a recordset - I created 5 rows of data.
My ASP Page seems to take forever to export this data(5 rows!!) to an Excel spreadsheet. This worked before. Nothing has changed.

Here is the code. I've checked that all objects are closed.

Here is the code:
Th calling function openes the Connection object and Closes it once CreateArray has finished.

public function CreateArray(arrData, icols)
'Creates an array from the SQL property and the currect connection property
Dim rst, irows
'Default the rows to zero
irows = 0
'Create the recordset
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open SQLString,Connection,3

'Check to see if any data is in the recordset
if not rst.eof then
rst.movelast
rst.movefirst
irows = rst.recordcount
icols = rst.fields.Count - 1

'redimensions the array to the exact same size as the recordset
'this way no additional resources are need to populate all the data from the array

Redim arrData(irows, icols)
irows = 0
do while not rst.eof
for i = 0 to icols
arrData(irows, i) = Cstr(rst.fields(i).Value)
next
irows = irows + 1
rst.movenext
loop

end if
set rst = nothing
CreateArray = irows
end function
Reply With Quote
  #2 (permalink)  
Old 04-19-04, 19:41
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Umm,... I don't know why your function is slow, but why aren't you using getrows() to build your array??
Reply With Quote
  #3 (permalink)  
Old 04-20-04, 04:09
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Speed Tips by Charles Carroll
http://www.learnasp.com/learn/speedtips.asp

Or perhaps the Web host is just slow.
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #4 (permalink)  
Old 04-20-04, 08:42
axapta axapta is offline
Registered User
 
Join Date: Apr 2004
Posts: 47
Hi Rockslide
How can I use it here?

Kind Regards

Quote:
Originally posted by rokslide
Umm,... I don't know why your function is slow, but why aren't you using getrows() to build your array??
Reply With Quote
  #5 (permalink)  
Old 04-20-04, 18:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
something similar to this...

Code:
public function GetArray()
  'Creates an array from the SQL property and the currect connection property
  Dim rst
  'Create the recordset
  Set rst = Server.CreateObject("ADODB.Recordset")
  rst.Open SQLString,Connection,3

  'Check to see if any data is in the recordset
  if not rst.eof then
    Dim arrReturn(rst.Fields.Count, rst.RecordCount)
    arrReturn() = rst.GetRows()
  end if
  set rst = nothing
  GetArray = arrReturn()
end function

Last edited by rokslide; 04-20-04 at 19:42.
Reply With Quote
  #6 (permalink)  
Old 04-21-04, 04:57
axapta axapta is offline
Registered User
 
Join Date: Apr 2004
Posts: 47
Thanks for this rokslide.
I'm getting closer. It is much faster now....
I get the correct asp page displayed when there are no records returned.
However when there are records, I get: Subscript out of range

The error is on the following line:

arrReturn()=rst.GetRows()

cheers
Reply With Quote
  #7 (permalink)  
Old 04-21-04, 14:10
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Quote:
Originally posted by axapta
Thanks for this rokslide.
I'm getting closer. It is much faster now....
I get the correct asp page displayed when there are no records returned.
However when there are records, I get: Subscript out of range

The error is on the following line:

arrReturn()=rst.GetRows()

cheers
Try just using:

arrReturn = rst.GetRows

GetRows should return an array, in which case, arrReturn() would be attempting to set the return of GetRows as a value in arrReturn, instead of making arrReturn the actual array itself.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #8 (permalink)  
Old 04-21-04, 15:28
thele thele is offline
Registered User
 
Join Date: Jun 2003
Location: Ohio
Posts: 108
and if that does not work, try to do a rst.MoveFirst, then use getrows.

`Le
Reply With Quote
  #9 (permalink)  
Old 04-21-04, 18:47
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
yeah, Thele is probably right, I can't remember how the complete array syntax works and I can't test in the cruddy office I am working out of atm.
Reply With Quote
  #10 (permalink)  
Old 04-26-04, 05:35
axapta axapta is offline
Registered User
 
Join Date: Apr 2004
Posts: 47
I'm only getting the **FIRST** element of the array

How do I loop through the array?
Here's my code:
Set rst = objConn.Execute(SQL)
'irows = rst.recordcount
'icols = rst.Fields.Count -1
If Not rst.EOF Then

arrData = rst.GetRows()
rst.Close
set rst=nothing

irows = UBound( arrData, 2 )
icols = UBound( arrData, 1 )

***need to loop through the array here
Reply With Quote
  #11 (permalink)  
Old 04-26-04, 22:58
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
for loop1 = 0 to iRows
for loop2 = 0 to iCols
response.write arrData(loop1, loop2)
next
next
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On