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 > EOF and Redim Errors using Getrows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-04, 13:10
axapta axapta is offline
Registered User
 
Join Date: Apr 2004
Posts: 47
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
Reply With Quote
  #2 (permalink)  
Old 04-20-04, 13:39
thele thele is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 04-20-04, 19:40
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
You can only redim the last value in a multi dimensional array....
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