Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:36 Der er 22 kommentarer og
1 løsning

Loop fejl?

Hmmm nogen der kan hjælpe mig med hvad der går galt her?



Kode:

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">
<tr>
<td width="100%" colspan="3" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="3"><b>Standardudstyr</b></font></td>
</tr>
<tr>
<td width="60%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="2"><b>Modelprogram</b></font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2"><b>Micra</b></font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2"><b>Micra Comfort</b></font></td>
</tr>
<tr>
<td width="60%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="2">1.0 l. 16V - 60 hk</font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">3-dørs</font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">3-dørs</font></td>
</tr>
<tr>
<td width="60%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="2">1.4 l. 16V - 82 hk</font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">&nbsp;</font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">5-dørs</font></td>
</tr>
<tr>
<td width="60%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="2"><b>Aktiv sikkerhed</b></font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">&nbsp;</font></td>
<td width="20%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="2">&nbsp;</font></td>
</tr>


<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs("udstyr")%></font></td>

<%
do while not rs2.eof
%>


<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

if kol2 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk2")%></font></td>'
end If

if kol3 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk3")%></font></td>'
end If

if kol4 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk4")%></font></td>'
end If

if kol5 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk5")%></font></td>'
end If

</tr>

<%
rs2.movenext
loop
rs2.close
%>


</table>


<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
</html>



Fejlkode:

Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

/test2/micraudstyr.asp, line 84

loop
^
Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:38 #1
Rettede nogen tabel fejl, nu ser koden sådanne ud, stadig samme fejl...

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">


<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs("udstyr")%></font></td>

<%
do while not rs2.eof
%>


<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

if kol2 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk2")%></font></td>'
end If

if kol3 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk3")%></font></td>'
end If

if kol4 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk4")%></font></td>'
end If

if kol5 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk5")%></font></td>'
end If

</tr>

<%
rs2.movenext
loop
rs2.close
%>


</table>


<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
</html>
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:42 #2
Har du prøvet at ændre

do while not rs2.eof
til

while not rs2.eof
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:43 #3
Jeg bruger selv denne:

While Not RS.EOF
  Response.Write "Noget fra databasen " & RS("felt")
  RS.MoveNext
WEND
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:44 #4
Så hvis du laver noget a la det jeg lige viste, tror jeg det kører
Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:44 #5
Rettede flere dumme fejl, men stadig samme fejlkode

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">

<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<%
do while not rs2.eof
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs2("udstyr")%></font></td>

<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

if kol2 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk2")%></font></td>'
end If

if kol3 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk3")%></font></td>'
end If

if kol4 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk4")%></font></td>'
end If

if kol5 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk5")%></font></td>'
end If

</tr>

<%
rs2.movenext
loop
rs2.close
%>

</table>
</center>
<br><br>

<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
</html>
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:45 #6
Hmmm....når du at læse noget af det jeg skriver?
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:47 #7
Skift denne linie
do while not rs2.eof
ud med denne
while not rs2.eof

og disse
rs2.movenext
loop
rs2.close

med disse
rs2.movenext
wend
rs2.close
Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:47 #8
Prøvede det, fik så denne fejlkode

Microsoft VBScript compilation error '800a0400'

Expected statement

/test2/micraudstyr.asp, line 59

wend
^
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:47 #9
skulle have været et svar
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:48 #10
huskede du at fjerne
do
i linien
do while not rs2.eof
Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:49 #11
Jepper

Den nye kode:

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">

<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<%
while not rs2.eof
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs2("udstyr")%></font></td>

<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

if kol2 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk2")%></font></td>'
end If

if kol3 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk3")%></font></td>'
end If

if kol4 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk4")%></font></td>'
end If

if kol5 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk5")%></font></td>'
end If

</tr>

<%
rs2.movenext
wend
rs2.close
%>

</table>
</center>
<br><br>

<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
</html>
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:52 #12
med den nye kode får du samme fejl?
Avatar billede mightythor Nybegynder
03. oktober 2002 - 09:55 #13
Microsoft VBScript compilation error '800a0400'

Expected statement

/test2/micraudstyr.asp, line 59

wend
^
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:56 #14
Der er flere fejl i din kode::

<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

Den skal ikke starte med <%
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 09:57 #15
Sorry, det er afslutningen på koden der er noget glat med.....brb
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 10:01 #16
Her er koden der vist nok virker, test den lige af:

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">

<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<%
While Not RS.EOF
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs2("udstyr")%></font></td>

<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1">' & rs2("uk1")
end If

if kol2 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1">' & rs2("uk2") & '</font></td>'
end If

if kol3 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1">' & rs2("uk3") & '</font></td>'
end If

if kol4 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1">' & rs2("uk4") & '</font></td>'
end If

if kol5 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1">' & rs2("uk5") & '</font></td>'
end If %>
</tr>
<%
RS.MoveNext
WEND 
%>

</table>
</center>
<br><br>

<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 10:04 #17
Vil meget gerne forklare hvad det var der var galt. du havde følgende kode:

<%
if kol1 = "checked" then
response.write '<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>'
end If

Du har startet med <% som fortæller at det efterfølgende er ASP kode, men her går det galt:
<%=rs2("uk1")%>
du "forsøger" at fortælle fortolkeren at du vil bruge ASP kode igen, UDEN at afslutte først, derfor ændrede jeg koden til:
& rs2("uk1") &
Avatar billede kichian Nybegynder
03. oktober 2002 - 10:06 #18
I øvrigt er
do while ....
'
loop

Præcis det samme som

While ...
Wend

Fordelen med at bruge do er, at do while loop har en søster do until loop.
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 10:07 #19
that's true
Avatar billede mightythor Nybegynder
03. oktober 2002 - 10:08 #20
Hmmm så får jeg nogen syntaks fejl

1 Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'Write'

/test2/micraudstyr.asp, line 36



Men ændrede det hele til:

<html>
<head>
<title> ::: Autonorden ::: </title>
</head>
<body bgcolor="#ffffff" text="#0000aa" link="#0000aa" alink="#0000aa" vlink="#0000aa">

<%
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("nissan.mdb")
sqlstmt = "select * from micraudstyr order by udstyr"
conn.execute (sqlstmt)
set rs2 = conn.execute(sqlstmt)
%>

<br><br>
<center>
<table width="95%" cellspacing="2" cellpadding="2" bgcolor="#bbbbbb" border="1" bordercolorlight="#aaaaaa" bordercolordark="#cccccc">

<%
kol1 = rs2("check1")
kol2 = rs2("check2")
kol3 = rs2("check3")
kol4 = rs2("check4")
kol5 = rs2("check5")
%>

<%
while not rs2.eof
%>

<tr>
<td width="50%" bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff"><font face="verdana" size="1"><%=rs2("udstyr")%></font></td>

<%
if kol1 = "checked" then
%>

<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk1")%></font></td>

<%
end If
%>

<%
if kol2 = "checked" then
%>

<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk2")%></font></td>

<%
end If
%>

<%
if kol3 = "checked" then
%>

<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk3")%></font></td>

<%
end If
%>

<%
if kol4 = "checked" then
%>

<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk4")%></font></td>

<%
end If
%>

<%
if kol5 = "checked" then
%>

<td bgcolor="#eeeeee" bordercolorlight="#aaaaaa" bordercolordark="#ffffff" align="center"><font face="verdana" size="1"><%=rs2("uk5")%></font></td>

<%
end If
%>

</tr>

<%
rs2.movenext
wend
rs2.close
%>

</table>
</center>
<br><br>

<%
conn.close
set conn = nothing
set sqlstmt = nothing
%>

</body>
</html>

Og nu virker det.... Du skal have tak for hjælpen, du får lige nogen point :)
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 10:11 #21
selv tak, takker for point.
Afhængig af IIS versionen, er der en performance gevinst ved at samle ASP koden i så store klumper som muligt, så fortolkeren ikke skal kontekst-switche så meget......(tror IIS version 5+ klarer det bedre, så hvis du bruger en windows 2000 server (eller professional), kan du bare se bort fra denne kommentar.
Avatar billede mightythor Nybegynder
03. oktober 2002 - 10:15 #22
Mit site ligger hos NetSite, og de kører med de nyeste win2k servers...

Det vigtigeste for mig var at få det til at virke :) når jeg får lidt mere tid, skal jeg tweake det så det er lidt bedre optimeret...

Men det er meget nemmere at arbejde udfra noget der fungerer :)
Avatar billede puppetmaster Nybegynder
03. oktober 2002 - 10:18 #23
:)
Good luck, enjoy.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester