Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_cdo thread: dynamic array diclaration


Message #1 by =?iso-8859-1?q?chadive=20bhanu?= <cbpr2@y...> on Fri, 10 Aug 2001 11:02:22 +0100 (BST)
what is the procedure followed in dynamically

declaring an array? Why I need this dynamic

declaration of the array, I am explaining below. My

purpose here is to store all the values of  a 

recordset fields in to an array.For that I am first

finding the count of records existing .



do until rs.EOF

      c=c+1

      rs.Movenext

 loop

      rs.Close



with this count I want to declare an array. which I am

doing as below.

 dim arr(c)

Here I am getting the error saying that only integer

constant has to passed

while array is declared.

once I am able declare array dynamically,  I can

transfer all the required

recordset field values in to array as below.



for j=0 to ubound(arr)-1

arr(j)=rs("req-field")

rs.MoveNext

next



Thanks in advance.





Message #2 by "Tomm Matthis" <matthis@b...> on Fri, 10 Aug 2001 06:19:05 -0400
You might want to look at the GetRows method of the recordset object.



Hope that helps.



-- Tomm



> -----Original Message-----

> From: chadive bhanu [mailto:cbpr2@y...]

> Sent: Friday, August 10, 2001 6:02 AM

> To: ASP CDO

> Subject: [asp_cdo] dynamic array diclaration

>

>

> what is the procedure followed in dynamically

> declaring an array? Why I need this dynamic

> declaration of the array, I am explaining below. My

> purpose here is to store all the values of  a

> recordset fields in to an array.For that I am first

> finding the count of records existing .

>

> do until rs.EOF

>       c=c+1

>       rs.Movenext

>  loop

>       rs.Close

>

> with this count I want to declare an array. which I am

> doing as below.

>  dim arr(c)

> Here I am getting the error saying that only integer

> constant has to passed

> while array is declared.

> once I am able declare array dynamically,  I can

> transfer all the required

> recordset field values in to array as below.

>

> for j=0 to ubound(arr)-1

> arr(j)=rs("req-field")

> rs.MoveNext

> next

>

> Thanks in advance.

>

>

>

Message #3 by Mustafa Shah <mustafa.shah@n...> on Sat, 11 Aug 2001 11:15:27 +0500
hello chadive;

	first you can get the record count of any recordset by property

rs.Recordcount

(only if u have set the rs.cursorlocation =3D aduseclient). then you 

dont need

to make a loop to count the recordset.



Secondly to declare a dynamic array i VB you have to do two steps.



'first declare the array as

	dim Arr() 'with emty parenthesis

'second redim the array with the variable size

	redim Arr(C)



hope it helps. if you need a bit more detail, u can mail me again



Regards

SMS



-----Original Message-----

From: chadive bhanu [mailto:cbpr2@y...]

Sent: Friday, August 10, 2001 3:02 PM

To: ASP CDO

Subject: [asp_cdo] dynamic array diclaration





what is the procedure followed in dynamically

declaring an array? Why I need this dynamic

declaration of the array, I am explaining below. My

purpose here is to store all the values of  a

recordset fields in to an array.For that I am first

finding the count of records existing .



do until rs.EOF

      c=3Dc+1

      rs.Movenext

 loop

      rs.Close



with this count I want to declare an array. which I am

doing as below.

 dim arr(c)

Here I am getting the error saying that only integer

constant has to passed

while array is declared.

once I am able declare array dynamically,  I can

transfer all the required

recordset field values in to array as below.



for j=3D0 to ubound(arr)-1

arr(j)=3Drs("req-field")

rs.MoveNext

next



Thanks in advance.







Message #4 by =?iso-8859-1?q?chadive=20bhanu?= <cbpr2@y...> on Mon, 13 Aug 2001 13:20:47 +0100 (BST)
It has helped me a lot. Thank you Mustafa.





Message #5 by =?iso-8859-1?q?chadive=20bhanu?= <cbpr2@y...> on Mon, 13 Aug 2001 13:20:20 +0100 (BST)
Getrows works fine to dynamically assign recordset

values to an array. 

 

 Thank you very much for your help.






  Return to Index