asp classic - vbscript won't return multidimensional array -
this getting annoying. following method contained in custom database class. query data recordset try convert data array w/o field names. appears working within function because setup response.write
check if there values. once out of function, things go haywire (the array not same).
public function to2array() dim a, x, columns columns = rs.fields.count rs.movefirst() x = 0 until rs.eof redim a(x+1,columns) y = 0 columns - 1 a(x,y) = rs.fields.item(y) response.write a(x,y) 'returns correct value next x = x + 1 rs.movenext() loop to2array = end function
i assign return array there appears nothing.
arr = db.to2array() response.write(arr(1,0)) 'returns nothing
can figure out i'm doing wrong?
- you can grow last dimension of vbscript array. need colsxrows array.
- to keep 'old' part of dynamic array, must redim preserve.
- to 2 dimensional array recordset, use .getrows - , avoid risks of 'rolling own'.
Comments
Post a Comment