Forums

ASP

This topic is locked

dynamically assigned dimensions

Posted 07 May 2002 05:17:46
1
has voted
07 May 2002 05:17:46 Benjamin Jackson posted:
i have created a 'do while' statement that returns all table names in my database and using 'select * from {my table names}' then, using 'for each' statement i have been able to return the name of all fields in my database. i cannot, for the life of me, figure out how to assign a variable the name of the field with a returned value of the same field....
ie if my field was documentid, i want to set
'dim documentid = rs("documentid"'. unfortunately, i am doing this in a loop and must assign the value in the loop while not knowing the name 'documentid'. i have tried to 'redim myarray(i)' but that's what it does is "redim" so that won't help, plus, i can't rs.recordcount to get out of the loop because i am using rs("field_name" and get a returned recordcount value of -1.

any help would be much appreciated.

thanks

Replies

Replied 08 May 2002 02:13:09
08 May 2002 02:13:09 Andrew Watson replied:
to late to think about this but the last bit...., can you not change the cursor type
of the recordset to return the record count?

Cheer
LEED


:: Son, im Thirty.... ::
Replied 08 May 2002 10:15:01
08 May 2002 10:15:01 johannes nel replied:

the cursor type should not influence the recordcount property. r u certain that u r not getting an empty rs?

as to assigning variables names from a dynamic value - it ain't posible, since memory allocation occurs during compelation(or in asp @ intepretation), and not @ runtime.
therefore u cannot go

dim i
for i = 0 to 100
dim variablei '' this doesnot make sense!!!
next

"i have tried to 'redim myarray(i)' but that's what it does is "redim" so that won't help" -- not quite clear but I presume you are losing values
then try:
Redim Preserve Variablename(length-1)

'' the preserve key word keeps the already assigned values in the array.

an array is the right road to walk, for this secanario





Replied 08 May 2002 14:41:51
08 May 2002 14:41:51 Benjamin Jackson replied:
excellent....."PRESERVE"! That is a fantastic option. Thanks for your help, i'll give it a shot.

Reply to this topic