This is asp classic using VBScript, and no, it ain't moving to .net anything, so don't even ask.
OK, so the classic way to get data out of a database is to use GetRows:
Dim MyRecords
Dim rs, conn
[...database opening stuff...]
If Not rs.EOF Then
MyRecords = rs.GetRows
End If
[...close database & set to Nothing...]
Note how MyRecords is not dimmed as an array; it only becomes one after the GetRows
call.
My question is, how do I do something similar without using GetRows
? For example, if the data needs to come from Request.Form
instead of the database? (Doing something like "If conditions are met, then get data from database, else get data from form, but display the data the same way regardless where it came from".)
There's an Array
function in vbScript, but it only creates one-dimensional arrays - it's kinda like a limited version of the Split
function, as far as I can tell. I need two dimensions. (Backwards two dimensions, no less, to match the way GetRows
works - i.e. the first dimension is the columns, the second dimension is the rows.)
I can't use dynamic arrays (Dim MyRecords()
, then later ReDim MyRecords(x,y)
) because then the GetRows
will throw an error.
Is there a way to do what I want, or do I have to resign myself to juggling two different arrays, one for the database, the other for the form? Or worse, use a Do While
loop to populate the array from the database... //shudder.