Results 1 to 2 of 2

Thread: Do --- Loop

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    2

    Unhappy

    Hey guy's

    Here's my code:
    ************
    Set rsResults = conn.Execute("SELECT * FROM Headlines WHERE Head_Date = '" & lcdate & "' ORDER By Head_Index Desc")
    if not rsResults.EOF then
    Response.Write "</blockquote><font face=""times new roman"" size=""5"" color=""#000000"">Today's Top Stories.</font><blockquote><ul type=""disc"">"
    Do
    if cstr(rsResults("Head_Date")) = lcdate then
    Response.Write "<li><a href=""javascript:Head('http://www.newsclip.co.za/asp/headline.asp?sHead=" & rsResults("Head_Index") & "')""><font face=""times new roman"" size=""3"" color=""RED"">" & rsResults("Head_Headline") & " <br> " & rsResults("Head_Time") & "</font></a>"
    i = i + 1
    rsResults.MoveNext()
    else
    Response.write "Error Retriving Data.<br>"
    end if
    Loop While i <> 4 'OR rsResults.EOF = True
    end if
    *******************
    My problem is that if I have less than 3 headlines to be added I get an error message Now I want to loop to run 3 times or until the end of the Recordset has been reached but It doesn't want to work that way.

    Thanks in advance
    I'm the terror that Slaps in the Night

  2. #2
    Guest

    Lightbulb

    Perhaps you can try this trick.
    Code:
    If Not rsResults.EOF Then 
      Do Until rsResults.EOF
        if cstr(rsResults("Head_Date")) = lcdate then 
          ' Place here your output code.
        Else
          Response.write "Error Retriving Data.<br>"
        End IF
        i = i + 1
        rsResults.MoveNext
      Loop
    End If
    And if you want to exit the loop you can use
    Code:
    If i = 3 Then
      Exit Do
    End If

Posting Permissions

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



Click Here to Expand Forum to Full Width