Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2004
    Posts
    47

    Unanswered: 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

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Umm,... I don't know why your function is slow, but why aren't you using getrows() to build your array??

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

  4. #4
    Join Date
    Apr 2004
    Posts
    47
    Hi Rockslide
    How can I use it here?

    Kind Regards

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

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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 20:42.

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

  7. #7
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    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.

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108
    and if that does not work, try to do a rst.MoveFirst, then use getrows.

    `Le

  9. #9
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

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

  11. #11
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    for loop1 = 0 to iRows
    for loop2 = 0 to iCols
    response.write arrData(loop1, loop2)
    next
    next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •