Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2004, 01:11 AM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'loop' without 'do' error!

I am trying to create an ASP page that displays two products per table row. Any ideas why I would be receiving a 'loop' without 'do' error based on the code I have attached??

          <%
              Dim counter
            counter = 0

              DO WHILE NOT objRS.EOF
                    IF counter = 0 THEN
                        Response.Write "<td width=""309"" class=""bodyText"">" & objRS("basketTitle") & "<br>" & objRS("basketDescription") & "</td>"
                        counter = 1
                    ELSE IF counter = 1 THEN
                        Response.Write "<tr><td width=""309"" class=""bodyText"">" & objRS("basketTitle") &"<br>" & objRS("basketDescription") & "</td>"
                        counter = 2
                    ELSE
                        Response.Write "<td width=""309"" class=""bodyText"">" & objRS("basketTitle") & "<br>" & objRS("basketDescription") & "</td></tr>"
                        counter = 1
                    END IF
                objRS.MoveNext
            LOOP

            %>

 
Old January 22nd, 2004, 01:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Try ELSEIF instead of ELSE IF.

What you code says is

DO WHILE ??
IF counter = 0 THEN
     'do something
ELSE
     IF counter = 1 THEN
     'do something
     ELSE
     'do Something
     END IF
     objRS.MoveNext
     LOOP

The loop above comes before the end of the first IF statement


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 22nd, 2004, 01:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

MORE:

Else if's are not really required for your situation

<%
    Dim counter
    counter = 0
    response.write("<TR>")
    DO WHILE NOT objRS.EOF
        Response.Write "<td width=""309"" class=""bodyText"">" & objRS("basketTitle") & "<br>" & objRS("basketDescription") & "</td>"
        if ((counter mod 2) > 0) then response.write("</TR><TR>")
        counter = counter + 1
        objRS.MoveNext
    LOOP
    response.write("</TR>")
%>


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 22nd, 2004, 07:58 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Works like a charm... thanks Rod!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error type: Loop without Do cannielynn0312 Classic ASP Basics 1 February 21st, 2008 09:15 AM
last occurance omitted - LOOP error? crmpicco Excel VBA 3 May 5th, 2005 01:45 PM
loop error crmpicco Classic ASP Databases 7 March 4th, 2005 10:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.