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 402,509 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,818 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: 3320 | Replies: 88 | Solved
Reply
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #21  
Feb 14th, 2008
Ok so let me get this.. this is exactly how you're doing it, but in tables right:

Category 1
Mid Cat 1
Mid Cat 2
Mid Cat 3

Category 2
Mid Cat 1
Mid Cat 2
Mid Cat 3
Mid Cat 4

And so on..

Is that right?
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #22  
Feb 14th, 2008
This is how I would do it then, completely:
If Not RS.EOF then
  Response.Write("<table width=""570"" border=""1"">")
  
  Do Until RS.EOF
    Response.Write("<tr>")

    For i = 1 To Cols
      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
          Response.Write("</td>")
          Flag1 = False
        Else
          RS.MoveNext
        End If
      End If
    Next

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

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

You have to set a new variable called "Flag1". Set it to False.

Glad to help.
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

  #23  
Feb 14th, 2008
the last code was crashed,

--
Response-objekt fel 'ASP 0251 : 80004005'
Svarsbuffertens längd har överskridits
/NYSITE/category_window.asp, rad 0
Körning av ASP-sidan gjorde att svarsbuffertens storlek överskreds.
--

I did some cut and paste in the earlier uotput source and this is what it should be compared to the one I send before.

<table width='570' border='1'>
<tr>
<td width='190'>Bil, Båt & Motor [Topcategory]<br>-----------------------------<br>
Bilservice [middlecategory]
Bilservice [middlecategory]
Bildelar & Biltillbehör [middlecategory]
</td>
<td width='190'>Butiker & Shopping [Topcategory]<br>-----------------------------<br>
Hälsa & Skönhet [middlecategory]
Bygg & Trädgård [middlecategory]
Hus, Hem & Trädgård [middlecategory]
Film, Musik & Spel [middlecategory]
Mobilt & Telefoni [middlecategory]
Kläder, Mode & Skor [middlecategory]
Glasögon & Kontaktlinser [middlecategory]
Hemelektronik & Foto [middlecategory]
Företag & Kontor [middlecategory]
</td>
<td width='190'>Data, IT & Telekommunikation [Topcategory]<br>-----------------------------<br>
Datorer & Nätverk [middlecategory]
Mobilt & Telefoni [middlecategory]
Internettjänster [middlecategory]
</td>
</tr>
<tr>
<td width='190'>Ekonomi & Juridik [Topcategory]<br>-----------------------------<br>
Advokat- & Juristbyråer [middlecategory]
Administration & Redovisning [middlecategory]
Bank, Finans & Egendom [middlecategory]
</td>
<td width='190'>Industri & Transport [Topcategory]<br>-----------------------------<br>
Åkeri & Transporttjänster [middlecategory]
</td>
<td width='190'>Marknadsföring & Media [Topcategory]<br>-----------------------------<br>
Reklam & Annons [middlecategory]
Internetmarknadsföring [middlecategory]
Design & Formgivning [middlecategory]
PR & Kommunikation [middlecategory]
</td>
</tr>
<tr>
<td width='190'>Sport & Fritid [Topcategory]<br>-----------------------------<br>
Äventyr & Naturupplevelser [middlecategory] </td>
<td width='190'>xx</td>
<td width='190'>xx</td>
</tr>
</table>
Last edited by TobbeK : Feb 14th, 2008 at 3:56 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #24  
Feb 14th, 2008
That's what the code will do. What happened is that the response.buffer limit was exceeded. Add this line right after the "Do" statement:

response.flush

and make sure that you have this line at the top of the file:

response.buffer="true"
Last edited by SheSaidImaPregy : Feb 14th, 2008 at 4:03 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

  #25  
Feb 14th, 2008
It hangs, no error

Here is my full code

response.buffer="true"
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 "
RS.Open SQL,Conn

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

Do Until RS.EOF
response.flush
Response.Write("<tr>")

For i = 1 To Cols
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
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #26  
Feb 14th, 2008
then try removing the response.flush and set response.buffer = false
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

  #27  
Feb 14th, 2008
Now it does hangs, but it keep on error
I can email you an Accessdatabase with the exakt tables as i have in my MySQL at this moment.
Last edited by TobbeK : Feb 14th, 2008 at 4:20 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #28  
Feb 14th, 2008
Its not that, it should work. If it isn't, it is because of settings on your server and you're grabbing way too many records for the recordset to loop through. Try this real quick, adding it on to your SQL statement

Add this onto your sql statement: " LIMIT 20"
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Nested loop

  #29  
Feb 14th, 2008
You should think about moving to ASP.NET

You don't have the old ASP limitations.
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

  #30  
Feb 14th, 2008
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.
Last edited by TobbeK : Feb 14th, 2008 at 4:29 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 5:59 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC