Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP query & logic 1

Status
Not open for further replies.

lecooper

Programmer
Sep 6, 2001
4
0
0
US
I want to:

sql = Select PhoneNum from table
open rs
If not rs.BOF then
Do While NOT rsEOF
Count = Count + 1
PhoneNum(count) = rs("PhoneNum")
rs.movenext
Loop
end if

and end with some variables:

PhoneNum1 = 590-1234
PhoneNum2 = 590-1235
PhoneNum3 = 590-1236

BUT
Count = Count + 1
PhoneNum(count) doesn't work!
Does anyone know how to increment a veriable?

Thanks!
Lyle
 
Add one line to your code, something like this:

If not rs.BOF then
Do While NOT rsEOF
Count = Count + 1
Redim Preserve PhoneNum(count)
PhoneNum(count) = rs("PhoneNum")
rs.movenext
Loop
end if

Good luck,
 
dwu1998
Thanks for your answer!
Ah! You have expanded my mind to a whole new part of ASP!
I was trying to do an array and didn't even know what an array was!
So far, I keep erring out when trying to use the "Preserve" word in your extra line, but at least I know what to look for. Here is what is happening so far.

If Not RSCkts.BOF Then
Do While Not RSCkts.EOF

Count=Count+1
Redim SpanNum(Count)
SpanNum(count)=RSCkts("SpanNum")
Response.Write SpanNum(count)
Response.Write &quot;<BR>&quot;
RSCkts.MoveNext
Loop
End If
'the above code nicely writes out all the SpanNums

sqlCkt2 = &quot;Select * from Ckts &quot;
'Count = 1
sqlCkt2=sqlCkt2 & &quot;where SpanNum ='&quot; & SpanNum(count) & &quot;'&quot;
sqlCkt2=sqlCkt2 & &quot;and Link = '1'&quot;

If I comment out Count = 1 (as shown) the sql select will select the first row of data. I have tried putting a number in like &quot;SpanNum(4)&quot; or using &quot;Count = 4)&quot; to pull out another line, but nothing works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top