Page 1 of 2 12 LastLast
Results 1 to 16 of 31

Thread: ASP Loop Issue..

  1. #1
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro

    ASP Loop Issue..

    Okay folks, it's gonna get messy

    I've trying to build a basic FAQ engine so we can add additional information to our products as and when the call centre finds something.

    I'm trying to get the code to first loop through the questions in one category before moving on to another (and eventually on to the FAQ answers in a similar fashion)..

    I've got the code listing through the categories as I want, but I hit an exception error before I can move on to the rest of the code.

    Code:
    	<%
    	strSQL = "SELECT * FROM FAQ WHERE SiteCode = '" & strSiteCode & "' AND InfoType = 'default' ORDER BY Category ASC;"
    	OpenDB()
    
    	Do While Not rsProdSearch.EOF
    
    		strCat = rsProdSearch("Category")
    		%><b><%=strCat%></b><br/><%
    
    		Do While rsProdSearch("Category") = strCat
    
    			%><a href="#<% = rsProdSearch("ID") %>"><%=rsProdSearch("Question")%>?</a><br/><%
    
    			If Not rsProdSearch.EOF then
    				rsProdSearch.MoveNext
    			end if
    
    		Loop
    
    		%><p/>!<%
    
    	Loop
    
    	%>Blah<p/><%
    
    	CloseDB()
    	%>
    	rest of code in here later..
    OpenDB and CloseDB open up the connection to the database, and work fine, so no need to worry about those
    The "!" and "Blah" are just a couple of pointers so I can see what the code is doing..

    The result is more or less:

    Code:
    Information
    
    Test
    Is this a test??
    Some Other Stuff?
    
    
    !Test2
    Some More Stuff to Do?
    Is this another Test??
    error '80020009' 
    
    Exception occurred. 
    
    /Intranet/includes/FAQ_page.asp, line 25
    Line 25 is " Do While rsProdSearch("Category") = strCat "

    I initally thought the MoveNext was causing the error from hitting the EOF while trying to loop, but adding the if statement didn't do anything, nor did changing the loop statement to add "AND Not rsProdSearch.EOF"..


    Any ideas? (Apart from telling me I create the messiest code in the world )
    Last edited by Stoo; 11-10-2004 at 04:32 PM.
    (\__/)
    (='.'=)
    (")_(")

  2. #2
    Pixel Abuser Spunkey's Avatar
    Join Date
    Nov 2003
    Location
    Milton Keynes
    Posts
    1,523
    Thanks
    0
    Thanked
    0 times in 0 posts
    what should come after 'Is this another Test??'

    is there another category/question or is that it?
    Last edited by Spunkey; 11-10-2004 at 04:44 PM.

  3. #3
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    There's only 2 categories at the moment, it should then break out of the loop and display the rest of the static content..
    (\__/)
    (='.'=)
    (")_(")

  4. #4
    Pixel Abuser Spunkey's Avatar
    Join Date
    Nov 2003
    Location
    Milton Keynes
    Posts
    1,523
    Thanks
    0
    Thanked
    0 times in 0 posts
    stwange... it seems to be looping around again even after it hits the EOF....

    possibly because after the final time around the interior loop, it again calls the exterior loop to start again, even thogh the RS is now EOF. Shouldnt in theory be a problem, but try this just to cover all bases..

    Code:
    	Do 
    		strCat = rsProdSearch("Category")
    		%><b><%=strCat%></b><br/><%
    
    		Do While rsProdSearch("Category") = strCat
    
    			%><a href="#<% = rsProdSearch("ID") %>"><%=rsProdSearch("Question")%>?</a><br/><%
    
    			If Not rsProdSearch.EOF then
    				rsProdSearch.MoveNext
    			end if
    
    		Loop
    
    		%><p/>!<%
    
    	Loop Until Not rsProdSearch.EOF
    hopefully that should work... although my brain is fried and i've lost al mental ability to run code in my head

  5. #5
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Okay, that works for the rest of the static page, but it misses the 2nd category out ..
    (\__/)
    (='.'=)
    (")_(")

  6. #6
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Using " Loop While Not rsProdSearch.EOF " on the outer loop has the same effect as the initial code (as it should)
    (\__/)
    (='.'=)
    (")_(")

  7. #7
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Changing the Do While to a Loop Until on the inner loop makes no difference either..

    *confused*

    Too Much Coding for a Monday..
    (\__/)
    (='.'=)
    (")_(")

  8. #8
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Oh, btw, it's currently runnning on the dev box which is a fairly elderly machine running IIS4 on NT4..

    Could that be the issue?
    (\__/)
    (='.'=)
    (")_(")

  9. #9
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    It's been a while, but I couldn't see where you assigned your SQL result to your recordset...

    like a line ....

    Set rsProdSearch= objConn.Execute(strSQL)

    Am I missing something, or are you having a really bad Monday?
    sig removed by Zak33

  10. #10
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    That's what the OpenDB() function does
    (\__/)
    (='.'=)
    (")_(")

  11. #11
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    So within your OpenDB() function you assign your SQL results to a hardcoded variable called rsProdSearch?

    Doesn't that kind of limit your OpenDB() function to calls that expect back a ProdSearch type result?
    sig removed by Zak33

  12. #12
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    Can you write down what your Category field contains in the DB, and alongside your rsProdSearch ID & Question fields?
    sig removed by Zak33

  13. #13
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Quote Originally Posted by ibm
    So within your OpenDB() function you assign your SQL results to a hardcoded variable called rsProdSearch?

    Doesn't that kind of limit your OpenDB() function to calls that expect back a ProdSearch type result?
    Stop getting hungup on the database connection, it's fine and works flawlessly in all situations

    Quote Originally Posted by ibm
    Can you write down what your Category field contains in the DB, and alongside your rsProdSearch ID & Question fields?
    You can already see most of it in one of the earlier posts, but here's the full list of the database..

    Code:
    ID	SiteCode	Question		Answer			Category InfoType
    1	TEST		Is this a test?		Stuff..			Test	default
    2	TEST		Is this another Test??	More Stuff..		Test2	default
    3	TEST		Some Other Stuff?	Yet More Stuff..	Test	default
    4	TEST		Some More Stuff to Do?	Yadda Yadda Yadda..	Test2	default
    But I really don't think it's a database problem, I think it's more likely to be hitting the EOF then trying to loop again..
    (\__/)
    (='.'=)
    (")_(")

  14. #14
    Member
    Join Date
    Aug 2003
    Location
    Wimbledon
    Posts
    141
    Thanks
    0
    Thanked
    0 times in 0 posts
    Are you using BLOBS in the DB?

    http://support.microsoft.com/kb/q175239/

  15. #15
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    no blobs, it's just a little access database (yes, I know, eww access etc, but that's all I've got to use at the moment and I can't change that, so don't moan ) with exactly the data you just read, an auto number field and 5 text fields..
    (\__/)
    (='.'=)
    (")_(")

  16. #16
    Member
    Join Date
    Aug 2003
    Location
    Wimbledon
    Posts
    141
    Thanks
    0
    Thanked
    0 times in 0 posts
    Actually...after reading your code again I would change your looping construct to:
    Code:
    Do While rsProdSearch("Category") = strCat AND rsProdSearch.EOF  = False
           %><a href="#<% = rsProdSearch("ID") %>"><%=rsProdSearch("Question")%>?</a><br/><%
           rsProdSearch.MoveNext
    Loop
    At the moment you movenext and it could hit EOF. If it is EOF and you try and access fields in the recordset but there is no valid record...*DANGER WILL ROBINSON*.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Microsoft Support....
    By Devilbod in forum General Discussion
    Replies: 14
    Last Post: 09-04-2007, 02:42 AM
  2. Learning ASP
    By TomWilko in forum Software
    Replies: 9
    Last Post: 02-10-2004, 04:28 PM
  3. Intel ICH6RW manufacturing issue
    By Steve in forum PC Hardware and Components
    Replies: 1
    Last Post: 25-06-2004, 10:06 PM
  4. Intel ICH6RW manufacturing issue
    By Steve in forum HEXUS Reviews
    Replies: 0
    Last Post: 25-06-2004, 04:37 PM
  5. sn41g2 wierd reboot issue :(
    By micovwar in forum PC Hardware and Components
    Replies: 7
    Last Post: 17-01-2004, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •