Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Recodset values fomr array values???


Message #1 by simon@h... on Tue, 19 Nov 2002 14:54:02
I have the following code which splits a string into seperate array values 
without the ",".
---------------------------------------------
Dim I, ArrayAssigned, strArrayValue, strArrayText, strAssigned, intNumber

strAssigned = Session("svProjectAssigned")
ArrayAssigned = split(strAssigned, ", ")
For I=0 to Ubound(ArrayAssigned)
Response.Write ArrayAssigned(I) & "<BR>"
Next
----------------------------------------------------

What I need is some code before the "Next" so that a variable gets 
the "Email" field from the recordset "rsUsers" relating to each value in 
the iteration of the array. 

FOR EXAMPLE...

ArrayAssigned(0)= Simon
strvariable0 = Simon@h...
ArrayAssigned(1)= James
strvariable1= james@h...
ArrayAssigned(2)= David
strvariable2 = David@h...
.
.
ArrayAssigned(n)= somename
strvairablen= some email address

Any help greatly appreciated 
Thank. Simon
Message #2 by Imar@S... on Tue, 19 Nov 2002 17:07:52
Hmmm, that depends on how they are related.

If there is a one to one relation between the array and the recordset in 
the same order, you can use the recordset directly between the for and 
next of the array:

For I = 0 to Ubound(ArrayAssigned)
    Response.Write ArrayAssigned(I) & "<BR>"
    strEmail = rsUsers("Email")
    rsUsers.MoveNext
Next

If there is no direct relation, you'll need to query the recordset for 
the right e-mail address. Requerying usually means a roundtrip to the 
database, so this can be a costly operation if the array is large.

In that case, you might want to reconsider your design so the recordset 
contains all the values you need.

HtH

Imar



> I have the following code which splits a string into seperate array 
values 
w> ithout the ",".
-> --------------------------------------------
D> im I, ArrayAssigned, strArrayValue, strArrayText, strAssigned, 
intNumber

> strAssigned = Session("svProjectAssigned")
A> rrayAssigned = split(strAssigned, ", ")
F> or I=0 to Ubound(ArrayAssigned)
R> esponse.Write ArrayAssigned(I) & "<BR>"
N> ext
-> ---------------------------------------------------

> What I need is some code before the "Next" so that a variable gets 
t> he "Email" field from the recordset "rsUsers" relating to each value 
in 
t> he iteration of the array. 

> FOR EXAMPLE...

> ArrayAssigned(0)= Simon
s> trvariable0 = Simon@h...
A> rrayAssigned(1)= James
s> trvariable1= james@h...
A> rrayAssigned(2)= David
s> trvariable2 = David@h...
.> 
.> 
A> rrayAssigned(n)= somename
s> trvairablen= some email address

> Any help greatly appreciated 
T> hank. Simon

  Return to Index