|
 |
asp_web_howto thread: Multidimensional Array
Message #1 by "COCO LUA SUAT CHOO" <cocolua@h...> on Thu, 28 Jun 2001 03:20:35
|
|
Hi!
I have a problem here
I want to have an 2 dimentional array which i don't know what the size is,
while looping the records that i select i will atcually store the record
that match my condition into my array, the problem is how to do it with
knowing how many record i have to make up my array until i reach the EOF...
anyone can help please?
here how the logic of the program
objRec.Open "SELECT ***.........."
WHILE NOT objRec.EOF
IF objRec("xxx") = tempabc Then
strABC(i,0) = objRec("xxx")
strABC(i,1) = objRec("yyy")
end if
objRec.MoveNext
wend
i can't do this because there's an error says that the i in the array
strABC() must be a integer
thanks a lot
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 28 Jun 2001 18:50:11 +1000
|
|
a) Why do you use a better query that restricts the records returned, so
that you can use .getRows and get it into an array of just the records you
want?
b) Why don't you just store all the records in the array using .getRows and
work on the array...
c) Last recommendation - Declare a dynamic array and use Redim Preserve (not
recommended at all!)
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "COCO LUA SUAT CHOO" <cocolua@h...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, June 28, 2001 3:20 AM
Subject: [asp_web_howto] Multidimensional Array
: Hi!
: I have a problem here
: I want to have an 2 dimentional array which i don't know what the size is,
: while looping the records that i select i will atcually store the record
: that match my condition into my array, the problem is how to do it with
: knowing how many record i have to make up my array until i reach the
EOF...
: anyone can help please?
: here how the logic of the program
:
: objRec.Open "SELECT ***.........."
: WHILE NOT objRec.EOF
: IF objRec("xxx") = tempabc Then
: strABC(i,0) = objRec("xxx")
: strABC(i,1) = objRec("yyy")
: end if
: objRec.MoveNext
: wend
:
: i can't do this because there's an error says that the i in the array
: strABC() must be a integer
: thanks a lot
Message #3 by ".box atm" <user_15@h...> on Thu, 28 Jun 2001 13:08:48 +0100
|
|
Determine the number of records you want from the data source by using the
adOpenStatic Key in your objRecordSet.Open command and also don't forget to
use the Cursor location of adUseClient (i.e objRecordSet.CursorLocation =
adUseClient (=3) ). Now that we have the number of records i.e count we
could limit the size of the array using UBound.
>From: "COCO LUA SUAT CHOO" <cocolua@h...>
>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
>To: "ASP Web HowTo" <asp_web_howto@p...>
>Subject: [asp_web_howto] Multidimensional Array
>Date: Thu, 28 Jun 2001 03:20:35
>
>Hi!
>I have a problem here
>I want to have an 2 dimentional array which i don't know what the size is,
>while looping the records that i select i will atcually store the record
>that match my condition into my array, the problem is how to do it with
>knowing how many record i have to make up my array until i reach the EOF...
>anyone can help please?
>here how the logic of the program
>
>objRec.Open "SELECT ***.........."
>WHILE NOT objRec.EOF
> IF objRec("xxx") = tempabc Then
> strABC(i,0) = objRec("xxx")
> strABC(i,1) = objRec("yyy")
> end if
> objRec.MoveNext
>wend
>
>i can't do this because there's an error says that the i in the array
>strABC() must be a integer
>thanks a lot
>
>
Message #4 by "Ken Schaefer" <ken@a...> on Fri, 29 Jun 2001 01:03:21 +1000
|
|
If you are going to create an array the size of the recordset, then just use
.GetRows - you can then use a fast server-side adOpenForwardOnly,
adLockReadOnly cursor/locktype
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: ".box atm" <user_15@h...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, June 28, 2001 10:08 PM
Subject: [asp_web_howto] Re: Multidimensional Array
: Determine the number of records you want from the data source by using the
: adOpenStatic Key in your objRecordSet.Open command and also don't forget
to
: use the Cursor location of adUseClient (i.e objRecordSet.CursorLocation
: adUseClient (=3) ). Now that we have the number of records i.e count we
: could limit the size of the array using UBound.
:
:
:
:
: >From: "COCO LUA SUAT CHOO" <cocolua@h...>
: >Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
: >To: "ASP Web HowTo" <asp_web_howto@p...>
: >Subject: [asp_web_howto] Multidimensional Array
: >Date: Thu, 28 Jun 2001 03:20:35
: >
: >Hi!
: >I have a problem here
: >I want to have an 2 dimentional array which i don't know what the size
is,
: >while looping the records that i select i will atcually store the record
: >that match my condition into my array, the problem is how to do it with
: >knowing how many record i have to make up my array until i reach the
EOF...
: >anyone can help please?
: >here how the logic of the program
: >
: >objRec.Open "SELECT ***.........."
: >WHILE NOT objRec.EOF
: > IF objRec("xxx") = tempabc Then
: > strABC(i,0) = objRec("xxx")
: > strABC(i,1) = objRec("yyy")
: > end if
: > objRec.MoveNext
: >wend
: >
: >i can't do this because there's an error says that the i in the array
: >strABC() must be a integer
: >thanks a lot
: >
Message #5 by Jerry Diegel <jerry.diegel@h...> on Thu, 28 Jun 2001 10:14:14 -0500
|
|
If your going to only use specific records from your recordset try to
adjust
your SQL query so that it only returns the records that your looking
for.
Then you can use GetRows like Ken is talking about. If, for some
reason,
you can't do this with your query then you could create a disconnected
recordset and put the records you want from the original recordset into
the
second. If you still need to you could then dump the disconnected
recordset
into an array with GetRows. Of course, it might be quicker ReDim'ing
your
array and just using one recordset. However, if you were to do
anything
like this you would definitely want your original recordset
ForwardOnly/LockReadOnly and you should probably put the whole chunk
inside
an object to save on performance.
Good Luck,
Jerry
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: Thursday, June 28, 2001 10:03 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: Multidimensional Array
If you are going to create an array the size of the recordset, then
just use
.GetRows - you can then use a fast server-side adOpenForwardOnly,
adLockReadOnly cursor/locktype
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: ".box atm" <user_15@h...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Thursday, June 28, 2001 10:08 PM
Subject: [asp_web_howto] Re: Multidimensional Array
: Determine the number of records you want from the data source by
using the
: adOpenStatic Key in your objRecordSet.Open command and also don't
forget
to
: use the Cursor location of adUseClient (i.e
objRecordSet.CursorLocation =3D
: adUseClient (=3D3) ). Now that we have the number of records i.e
count we
: could limit the size of the array using UBound.
:
:
:
:
: >From: "COCO LUA SUAT CHOO" <cocolua@h...>
: >Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
: >To: "ASP Web HowTo" <asp_web_howto@p...>
: >Subject: [asp_web_howto] Multidimensional Array
: >Date: Thu, 28 Jun 2001 03:20:35
: >
: >Hi!
: >I have a problem here
: >I want to have an 2 dimentional array which i don't know what the
size
is,
: >while looping the records that i select i will atcually store the
record
: >that match my condition into my array, the problem is how to do it
with
: >knowing how many record i have to make up my array until i reach the
EOF...
: >anyone can help please?
: >here how the logic of the program
: >
: >objRec.Open "SELECT ***.........."
: >WHILE NOT objRec.EOF
: > IF objRec("xxx") =3D tempabc Then
: > strABC(i,0) =3D objRec("xxx")
: > strABC(i,1) =3D objRec("yyy")
: > end if
: > objRec.MoveNext
: >wend
: >
: >i can't do this because there's an error says that the i in the
array
: >strABC() must be a integer
: >thanks a lot
: >
|
|
 |