PDA

View Full Version : 'loop' without 'do'


hughesmi
08-01-2008, 08:41 AM
I know i missing the "do" but for the life of me i cant figure the problem out. Can someone help, please.

Error


Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

testpage2.asp, line 26

Loop
^



The code



<%
DIM mySQL, objRS
'mySQL = "SELECT * FROM tblData"
mySQL = "SELECT * FROM products ORDER BY pDateAdded DESC"
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("pLargeImage")&"</td>"
ELSE
Response.Write "<td>"&objRS("pLargeImage")&"</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
%>

hughesmi
08-01-2008, 08:50 AM
recCount = recCount + 1
objRS.MoveNext
END IF
Loop


I am so dumb!

hughesmi
08-01-2008, 09:26 AM
Sorry I am back.

I am again trying to display only the first 10 records. Here is what I have so far. Could some point me in the right direction


<%
DIM mySQL, objRS
mySQL = "SELECT * FROM products ORDER BY pDateAdded DESC"
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
DO WHILE NOT objRS.EOF and recCount <> 10

IF recCount Mod 3 = 0 THEN

IF recCount <> 0 THEN
Response.Write "</tr>"
Response.Write "<tr><td>"&objRS("Item")&"</td>"
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
%>

robojob
08-03-2008, 12:42 PM
the simplest way would be to perform the limit in the query like this:


mySQL = "SELECT * FROM products ORDER BY pDateAdded DESC LIMIT 10"