PDA

View Full Version : 'loop' without 'do'


hughesmi
04-06-2005, 08:42 PM
I getting this error and I can't fugure out where I'm screwing up, Can anyone help?


Error Type:
Microsoft VBScript compilation (0x800A040E)
'loop' without 'do'
/TEST/tickertest/newview.asp, line 28
Loop


Code:

<!--#INCLUDE FILE="connection.asp" -->

<%
DIM mySQL, objRS
mySQL = "SELECT * FROM news"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn

DIM recCount
IF Not objRS.EOF THEN
Response.Write "<table width='100%'>"

recCount = 0

Do Until objRS.EOF

IF recCount Mod 3 = 0 THEN

IF recCount <> 0 THEN
Response.Write "</tr>"
Response.Write "<tr><td>"&objRS("Item")&"</td>"
ELSE
Response.Write "<td>"&objRS("Item")&"</td>"
END IF

recCount = recCount + 1
objRS.MoveNext
Loop

Response.Write"</tr></table>"

'ELSE
'Response.Write "Sorry, there are no records in our database."
'END IF
%>

oracleguy
04-06-2005, 09:41 PM
<!--#INCLUDE FILE="connection.asp" -->

<%
DIM mySQL, objRS
mySQL = "SELECT * FROM news"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn

DIM recCount
IF Not objRS.EOF THEN
Response.Write "<table width='100%'>"

recCount = 0

Do Until objRS.EOF

IF recCount Mod 3 = 0 THEN

IF recCount <> 0 THEN
Response.Write "</tr>"
Response.Write "<tr><td>"&objRS("Item")&"</td>"
ELSE
Response.Write "<td>"&objRS("Item")&"</td>"
END IF

recCount = recCount + 1
objRS.MoveNext
End If
Loop

Response.Write"</tr></table>"

'ELSE
'Response.Write "Sorry, there are no records in our database."
'END IF
%>


The error is coming up because you have an unterminated If statement (the blue one) before the loop command.

hughesmi
04-06-2005, 09:50 PM
Thanks.

glenngv
04-07-2005, 03:20 AM
You should make it a habit to indent your code so that it's more readable and easier to debug. Had you indent it, you could have clearly seen that you missed the End If statement.