Double Looping Database output

Results 1 to 2 of 2

Thread: Double Looping Database output

  1. #1
    sarina Guest

    Default Double Looping Database output

    OK, so I have this script, in which I"m trying to spout a list of articles for our intranet. The article names/file names are in a table in a database. I want to pull up a month, and have all the articles from that month listed. I can get this script to work for January only. It will output the other month names, but none of the articles. What am I missing?<BR><BR>&#060;%<BR>set connnews = server.createobject("ADODB.Connection")<BR>connnew "AANews"<BR><BR>SQLSTATE="SELECT * FROM Articles WHERE Type=2 "<BR><BR><BR>SQLMONTH="SELECT Months.* FROM Months"<BR>set months=connnews.execute(SQLMONTH)<BR><BR>do while not months.eof<BR>response.write ("&#060;b&#062;"& months("Month") & "&#060;/b&#062;<BR>")<BR>SQLSTATE=SQLSTATE & " AND Month=" & months("MonthID")<BR>set article=connnews.execute(SQLSTATE)<BR><BR>do while not article.eof<BR>response.write ("&#060;img src=../../../../Images/bulletgrn.gif width=16 height=16&#062;&nbsp;&#060;a class=plainlink href=" & article("FileName") & "&#062;" & article("Date") & ":&nbsp" & article("ArticleTitle") & "&#060;/a&#062;<BR>")<BR><BR>article.movenext<BR>loop<BR>r esponse.write ("&#060;p&#062;<BR>")<BR><BR>months.movenext<BR>lo op<BR>connnews.close<BR><BR>%&#062; <BR><BR>Here&#039s what gets output:<BR><BR>January<BR> 01/31/00: Technology Shift: Online Trading Just Begining to <BR> 01/28/00: Broker-to-Broker Networks Selects OM Technology to<BR><BR>February<BR><BR>March<BR><BR>April<BR><B R>May<BR><BR>June

  2. #2
    Join Date
    Dec 1969

    Default You're going to love this one!

    &nbsp;<BR>Rather than tell you the answer, I&#039m going to ask you to add just a *TINY* bit of DEBUG code.<BR><BR>Add in *ONE* debug line:<BR><BR>&#060;%<BR>...<BR>SQLSTATE=SQLSTATE & " AND Month=" & months("MonthID")<BR>Response.Write "SQLSTATE is " & SQLSTATE & "&LT;BR&#062;" &#039 &lt;&lt;&lt; --- add this line!!<BR>set article=connnews.execute(SQLSTATE)<BR>...<BR>%&#06 2;<BR><BR>*NOW* run the page. *NOW* tell us what is wrong.<BR><BR>Personally, I think SQL is doing just *exactly* what you are asking it to do. (HUGE grin)<BR><BR><BR>

Posting Permissions

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