...

View Full Version : Subscript Error



tazdog
08-19-2004, 02:03 AM
Trying to nail down this error I got:

Subscript out of range: '501'

Here is the code:
Dim AirportID(500)
Dim Cnt
Dim CntA
Dim ArTime
Dim DeTime

Cnt = 0

strSQL = "SELECT Name FROM Airports ORDER BY Name ASC"
RS.Open strSQL,CONN,1,1

Do Until RS.EOF
AirportID(Cnt) = RS.Fields("Name")
Cnt = Cnt + 1
RS.MoveNext
Loop

RS.Close

** The ERROR is stating the Line that starts with AirportID, thats where I get the 501 error.. **

Any help would be great, or pointers..!!!

I'm not a real good asp\db programmer and in fact someone else did this, but I'm trying to learn and since this broke, i thought what the heck..

thanks
Scott

tazdog
08-19-2004, 02:41 AM
I think the problem is within the data..

Sorry to waste bandwidth on this one

Scott

Morgoth
08-19-2004, 03:29 AM
What is AirportID(0 to 500) equal? Just ID numbers? Where did you get those ID numbers, they didn't just appear out of no where.

Is this all the asp code related to the problem?

glenngv
08-19-2004, 04:45 AM
You need to ReDim the array to the number of records retrieved.
But the best solution is to use getRows() to automatically put the contents of the recordset to array.

Dim AirportID
...
strSQL = "SELECT Name FROM Airports ORDER BY Name ASC"
RS.Open strSQL,CONN,1,1

AirportID = RS.getRows()

RS.close()
set RS = nothing

...

Morgoth
08-19-2004, 08:37 AM
You need to ReDim the array to the number of records retrieved.
But the best solution is to use getRows() to automatically put the contents of the recordset to array.

Dim AirportID
...
strSQL = "SELECT Name FROM Airports ORDER BY Name ASC"
RS.Open strSQL,CONN,1,1

AirportID = RS.getRows()

RS.close()
set RS = nothing

...

I'm an idiot, I didn't even read the code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum