Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: ASP DYNAMIC ARRAY


Message #1 by "sagar raut" <sagar@n...> on Tue, 18 Feb 2003 11:42:21
Hi,

I am trying to create a vbscript array which is getting generated from 
database. I want to create the array dynamically, that is I want the size 
of array to be same as the recordset count.

Some this like this:

set con = server.createobject("adodb.connection")
set rsads1 = server.createobject("adodb.recordset")
con.Open conn1
sqlads1="select * where a.pid =4728 and a.pid = b.pid and a.active <> 'Y'"
rsads1.Open sqlads1,con,3
dim intval
intval=0
intval = rsads1.RecordCount
Dim famname(intval) 'this is where i get error  
i=0
while not rsads1.eof
   famname(i)= rsads1("cid") &"|"& rsads1("priceb")
   i=i+1
   rsads1.MoveNext
wend


Please help me in this.

Thanks and Regards,
Sagar
Message #2 by "laeg byrne" <laeg_enterprises@y...> on Thu, 27 Feb 2003 11:07:26
Declare your array. Dim myarray().To use the recordCount functionality you 
must make sure that the type of pointer you are using is adOpenStatic. 
Then simple type this line Redim myarray(rsads1.recordcount), if you are 
using this array again further on and wish to append new results into it
then use the Preserve keyword,ie Redim Preserve myarray(rsads1.recordcount)

Laeg

> Hi,

> I am trying to create a vbscript array which is getting generated from 
d> atabase. I want to create the array dynamically, that is I want the 
size 
o> f array to be same as the recordset count.

> Some this like this:

> set con = server.createobject("adodb.connection")
s> et rsads1 = server.createobject("adodb.recordset")
c> on.Open conn1
s> qlads1="select * where a.pid =4728 and a.pid = b.pid and a.active 
<> 'Y'"
r> sads1.Open sqlads1,con,3
d> im intval
i> ntval=0
i> ntval = rsads1.RecordCount
D> im famname(intval) 'this is where i get error  
i> =0
w> hile not rsads1.eof
 >   famname(i)= rsads1("cid") &"|"& rsads1("priceb")
 >   i=i+1
 >   rsads1.MoveNext
w> end

> 
P> lease help me in this.

> Thanks and Regards,
S> agar

  Return to Index