Desperat

ASP

3 svar · 190 visningar · startad av aleborg

Medlem sedan jan. 20013 341 inlägg
Trådstart#1

Kan man inte köra två "Do until" i en loop?
I den här koden så körs inte "Do Until co.EOF" andra gången!


<% 
SqlCo="Select * From Countries Where Belongs=''"
Set cou=Conn.Execute(SqlCo)
Do Until cou.EOF
coSQL= "Select * From Countries Where Belongs="& cou("CountryID")
Set co=Conn.Execute(coSQL)
%>
<td width="25"><input type="radio" value="<%=cou("CountryID")%>" name="countrie"
<% 
Do Until co.EOF
If CInt(user("CountryBel"))=co("CountryID") then 
%>
 checked
<% 
End If
co.MoveNext
Loop
%>></td>
							<td width="263"><select name="CountryBel" size="1">
                <% Do Until co.EOF %>
                <option value="<%=co("CountryID")%>"<% If CInt(user("CountryBel"))=co("CountryID") then %> selected<% End If %>><%=co("CouName")%></option>
                <%
co.MoveNext
Loop
co.Close
Set co=Nothing
%>
              </select></td>
<%
cou.MoveNext
Loop
cou.Close
Set cou=Nothing
%>

Jag har tagit bort massor av HTML som vanligt för att ni lättare ska kunna läsa ut allt :)

Medlem sedan jan. 20013 341 inlägg
#2

provade det här med:

<% 
SqlCo="Select * From Countries Where Belongs=''"
Set cou=Conn.Execute(SqlCo)
Do Until cou.EOF

coSQL= "Select * From Countries Where Belongs="& cou("CountryID")
Set co=Conn.Execute(coSQL)

Do Until co.EOF
If CInt(user("CountryBel"))=co("CountryID") then 
koll=" checked"
koll2=" selected"
End If
selec="<option value="& co("CountryID") &""& koll2 &">"& co("CouName") &"</option>"

co.MoveNext
Loop
%>
<td width="25"><input type="radio" value="<%=cou("CountryID")%>" name="countrie"<%=koll%>></td>
							<td width="263"><select name="CountryBel" size="1">
                <%=selec%>
              </select></td>
<%
co.Close
Set co=Nothing
cou.MoveNext
Loop
cou.Close
Set cou=Nothing
%>

men då får jag bara upp 1 land i varje select :(

Medlem sedan dec. 19996 721 inlägg
#3

Du kan inte köra två until co.eof på en gång, utan att köra en movefirst emellan.

Jag ser inte riktigt vad det åär du försöker göra, men om du verkligen vill loopa igenom samma sak flera gånger kan jag rekommendera att du gör en array med getrows.

Medlem sedan jan. 20013 341 inlägg
#4

nu kom du in på min starka sida inom ASP, array med getrows.......NOT :e

jag tror jag håller mig till movefirst :)

524 ms totalt · 4 externa anrop · v20260731065814-full.d34c6d5a
391 ms — deklarationer (db)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)
397 ms — ändringar (db)