| |
|
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.
|
 |

04-19-04, 11:16
|
|
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
|
|

04-19-04, 19:41
|
|
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??
|
|

04-20-04, 04:09
|
|
Guru
|
|
Join Date: Jun 2003
Location: USA
Posts: 1,032
|
|
|
|

04-20-04, 08:42
|
|
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??
|
|
|

04-20-04, 18:56
|
|
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.
|

04-21-04, 04:57
|
|
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
|
|

04-21-04, 14:10
|
|
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.
|
|

04-21-04, 15:28
|
|
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
|
|

04-21-04, 18:47
|
|
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.
|
|

04-26-04, 05:35
|
|
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
|
|

04-26-04, 22:58
|
|
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|