How to declare the result of a loop as a variable?

K

Ken Fine

I'm trying to include a list of people that's the result of looping through
a recordset in a CDONTS mail. I'm trying to Dim the output of a loop, and it
ain't working -- I'm getting a syntax error. Any ideas why the following
snippet isn't working?

<%
Dim ConfirmedSpeakerList2
ConfirmedSpeakerList2=(While ((Repeat1__numRows <> 0) AND (NOT
rsConfirmedSpeakers.EOF))
(rsConfirmedSpeakers.Fields.Item("Per_GivenName").Value)

Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsConfirmedSpeakers.MoveNext()
Wend)%>

<%Response.Write ConfirmedSpeakerList2%>

I have the feeling I may be about to learn an unfortunate lesson, but...
wait and see.

Are there other ways that I could get looped output embedded in a CDONTS
mail? I thought trying to Dim the output of the recordset as a big long
string would be the cleanest way to make this happen.

Many thanks.
 
R

Ray at

I ~think~ this is what you're trying to do.

sResult = ""
Do while Not rsConfirmedSpeakers.EOF and Repeat1_numRows <> 0
sResult = sResult &
rsConfirmedSpeakers.Fields.Item("Per_GivenName").Value
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsConfirmedSpeakers.MoveNext()

Loop

Response.Write sResult

Ray at work
 
K

Ken Fine

Thanks for the help. Unfortunately, this code is returning nothing into the
var sResult, when I know there is content to be had in the recordset. Can
you think of any obvious error in the code which might be blanking out the
variable?
 
R

Ray at

The lesson to be learned is that a loop does not return a result. A loop is
just a flow. Is your loop even being entered? Are your conditions true?
Try adding

response.write "looping"

in your loop. If you don't see that at all, your loop is being bypassed.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top