User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,218 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,201 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 3641 | Replies: 88 | Solved
Reply
Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Nested loop

  #31  
Feb 14th, 2008
Originally Posted by TobbeK View Post
I'm old fashion guy so I will stick to the classic. You are right I should update myselfl and my coding some day.

Can i send you the access db. I have make it with the same table structure and names. Maybe it easier to see it live.

There is only 20 posts in the DB so it should not hang things up.

I have tested the LIMIT 20 and there still erroring.


There you have the zipped test db
Attached Files
File Type: zip labdb.zip (32.2 KB, 2 views)
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #32  
Feb 14th, 2008
I won't be able to look at it for about 2-3 hours. I don't have access on this machine. Well wait.. let me see. I'll get back to you.
Reply With Quote  
Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Nested loop

  #33  
Feb 14th, 2008
Here you have the zipped db anyway
Last edited by TobbeK : Feb 14th, 2008 at 4:37 pm.
Attached Files
File Type: zip labdb.zip (31.3 KB, 0 views)
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #34  
Feb 14th, 2008
hey, want to know why it errors? lol

It is never finding an end. There's a mistake in the code, and it's where it says "cols"

Remove cols, and have just "3".

For i=1 to 3

And it wont hang. Enjoy.

Oh, also remove response.buffer, and the response.flush.
Last edited by SheSaidImaPregy : Feb 14th, 2008 at 5:13 pm.
Reply With Quote  
Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Nested loop

  #35  
Feb 14th, 2008
Nope :-)

Check the attach

SQL = "SELECT DISTINCT TC.topcategory,MC.middlecategory "&_
"FROM tbtopcategory TC,tbmiddlecategory MC,tbconnectcategory CC "&_
"WHERE TC.topcategoryID = CC.topcategorylink "&_
"AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
"GROUP BY TC.topcategory,MC.middlecategory ASC "
RS.Open SQL,Conn

If Not RS.EOF then
Response.Write("<table width='570' border='1'>")

Do Until RS.EOF

Response.Write("<tr>")

For i = 1 To 3
If Not RS.EOF Then
TopCat = RS("topcategory")
MiddleCat = RS("middlecategory")

If LastTopCat <> TopCat and Flag1 = False Then
Response.Write("<td width='190'>")
End If

If LastTopCat <> TopCat and Flag1 = False Then
Response.Write(RS("topcategory") & "<br>")
Response.Write("-----------------------------<br>")
LastTopCat = TopCat
Flag1 = True
End If

If MiddleCat <> "" and LastTopCat = TopCat and Flag1 = True Then
Response.Write(MiddleCat)
End If

If LastTopCat <> TopCat and Flag1 = True Then
Response.Write("</td>")
Flag1 = False
Else
RS.MoveNext
End If
End If
Next

Response.Write("</tr>")
loop

Response.Write("</table>")
End If

Conn.Close
Attached Images
File Type: jpg table_9.jpg (174.8 KB, 1 views)
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #36  
Feb 14th, 2008
lmao. Doing 4 different tasks is a bit much for me I guess. Of course that won't work lol.

Try this:
If Not RS.EOF then
  Response.Write("<table width=""570"" border=""1"">")
  
  Do Until RS.EOF
    Response.Write("<tr>")

    For i = 1 To 3
      If Not RS.EOF Then
        Response.Write("<td width='190'>")

        Do Until LastTopCat <> TopCat
          TopCat = RS("topcategory")
          MiddleCat = RS("middlecategory")

          If LastTopCat <> TopCat Then
            Response.Write(RS("topcategory") & "<br>")
            Response.Write("-----------------------------<br>")
            LastTopCat = TopCat
          End If

          If MiddleCat <> "" and LastTopCat = TopCat Then
            Response.Write(MiddleCat)
          End If

          RS.MoveNext
        Loop

        Response.Write("</td>")
      End If
    Next

    Response.Write("</tr>")
  Loop

  Response.Write("</table>")
End If
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #37  
Feb 14th, 2008
That won't work either. Hold on, let me put everything else aside for a minute.
Reply With Quote  
Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Nested loop

  #38  
Feb 14th, 2008
ADODB.Field (0x800A0BCD)
Antingen är BOF eller EOF satt till True, eller så har aktuell post raderats. Den begärda åtgärden kräver en aktuell post.
/NYSITE/category_window.asp, line 27

And line 27 is:
TopCat = RS("topcategory")
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #39  
Feb 14th, 2008
Ok it will, but you have to add this line after
RS.MoveNext

TopCat = RS("topcategory")


You need a second one there in order to reset the topcat. Keep both. Just add that line after RS.MoveNext and it should work.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #40  
Feb 14th, 2008
Oh yeah forgot to check for EOF on that portion. Here you go:
If Not RS.EOF then
  Response.Write("<table width=""570"" border=""1"">")
  
  Do Until RS.EOF
    Response.Write("<tr>")

    For i = 1 To 3
      If Not RS.EOF Then
        Response.Write("<td width='190'>")

        Do Until LastTopCat <> TopCat
          If Not Rs.EOF Then
            TopCat = RS("topcategory")
            MiddleCat = RS("middlecategory")

            If LastTopCat <> TopCat Then
              Response.Write(RS("topcategory") & "<br>")
            Response.Write("-----------------------------<br>")
              LastTopCat = TopCat
            End If

            If MiddleCat <> "" and LastTopCat = TopCat Then
              Response.Write(MiddleCat)
            End If

            RS.MoveNext

            If Not RS.EOF Then
              TopCat = RS("topcategory")
            End If
          End If
        Loop

        Response.Write("</td>")
      End If
    Next

    Response.Write("</tr>")
  Loop

  Response.Write("</table>")
End If
Last edited by SheSaidImaPregy : Feb 14th, 2008 at 5:43 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 11:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC