Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2004, 01:11 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
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

            %>

Reply With Quote
  #2 (permalink)  
Old January 22nd, 2004, 01:32 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
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.
======================================
Reply With Quote
  #3 (permalink)  
Old January 22nd, 2004, 01:41 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
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.
======================================
Reply With Quote
  #4 (permalink)  
Old January 22nd, 2004, 07:58 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Works like a charm... thanks Rod!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:30 AM.


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