I need to retrieve one specific value from a list of values stored in an array using an index position value.
This is the location reference coming from url parameter:
Dim currentorder
Dim nextorderindex
Dim rowindex
Dim iArray
Dim i
currentorder = Trim(Request.QueryString("order"))
rowindex = CINT(Trim(Request.QueryString("rowindex"))) 'e.g. let's say this is a 4
SQLOrderList = "SELECT orderno" & _
" FROM awd_order" & _
" WHERE order_date >= '" & dtstart & " 00:00:00'" & _
" AND order_date < '" & dtend & " 23:59:59'" & _
" ORDER BY " & sortby
objRS.Open SQLOrderList, objConn
i = objRS.RecordCount 'e.g. this contains 7 records
If Not rowindex >= (i - 1) Then 'e.g. 4 >= (7 - 1)
nextorderindex = (rowindex + 1) 'e.g. then nextorderindex = 5
End If
'Get recordset to Array
iArray = objRS.GetRows()
If nextorderindex > 0 Then 'e.g. nextorderindex is 5
response.write iArray(nextorderindex) 'e.g. here is my issue, I get: subscript out of range error
Else
response.write currentorder
End If
Option Explicitat the beginning of your code. This enforces the declaration of variables and prevents problems that you may get later on.