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

    Unanswered: EOF and Redim Errors using Getrows

    Hi Group,
    I had a function that was running slow. It was suggested that I use the GetRows method which I've now used and it is much quicker.

    However, I have a couple of issues:

    1. How do I redim the array
    When I use the following line:Redim arrData(irows, icols) , the process is slow again. When I use: Redim allData(irows, icols) I get an error saying that it is not supported.


    2. How do I check for EOF or BOF?

    I receive this error if there are no records returned by the query:
    ADODB.Recordset error '800a0bcd'
    Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.

    Here is my code:

    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
    allData=rst.GetRows
    'Check to see if any data is in the recordset


    irows=ubound(allData,2)
    icols=ubound(allData,1)


    *****Redim arrData(irows, icols) ****
    do while not rst.eof
    irows=0
    for rowcounter = 0 to irows
    for colcounter=0 to icols
    allData(rowcounter,colcounter)=Cstr(rst.fields(col counter).Value)
    next
    next
    loop
    set rst = nothing
    CreateArray = irows
    end function

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108

    Post

    first off, check the recordset for EOF first. If it is, then end the code. If it is not, THEN use the getrows()

    second, try to redim with PRESERVE"
    REDIM PRESERVE MyArray(20)

    This wll keep all the data in the array without deleting it.

    There may be a problem rediming a multidimensional array.

    ~Le

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    You can only redim the last value in a multi dimensional array....

Posting Permissions

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