Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 5 of 5

Thread: ASP LOOP?

  1. #1

    ASP LOOP?

    ok. i'm a newb to asp, but here it goes

    im making a news updater thinger.

    heres the code i have so far.

    Code:
     <%
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("news/news.mdb")
    set RS = Conn.Execute("SELECT TOP 3 * FROM updates ORDER BY date DESC;")
    DO UNTIL RS.eof 
    id = RS("id")
    date = RS("date")
    title = RS("title")
    body = RS("body")
    user = RS("user")
     
    response.write "<div class=""asset""><strong>"& title & "<br><br><strong>"& date & "- by </strong>"& user &"<br><br>"& body &"</div>"
    RS.movenext
    LOOP
    %>
    <%
    RS.close
    set RS = nothing
    Conn.close
    set Conn = nothing
    %>
    now, with my luck, the whole thing will be wrong.

    it turns up the error.....
    Code:
    
    Microsoft VBScript compilation error- Error '800a040e'
    
    'loop' without 'do' 
    
    /home.asp, line 72 LOOP^
    thanks for any help.
    -Naaman

  2. #2
    Instead of Do Until...Loop, use:

    While Not RS.EOF
    ...
    Wend

    Hope that helps
    Formerly GWing_02

  3. #3
    hey, thanks for your help.

    i did that, and it turned up this error.


    Code:
     
    Microsoft VBScript runtime error- Error '800a01a8' 
    
    Object required: 'Conn' 
    
    /home.asp, line 62

    and how does the code look? this is my first real asp page, so i hope in the right direction

    -Thanks for the help

  4. #4
    try this

    Code:
    <%
    Set Conn = Server.CreateObject("ADODB.Connection")
    lpath =  "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("news/news.mdb")
    Conn.Open(lpath)
    set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open "SELECT TOP 3 * FROM updates ORDER BY date DESC", Conn
    If Not(RS.EOF) then 
    RS.MoveFirst()
    While NOT  RS.eof 
     id = RS.Fields.Item("id")
     date = RS.Fields.Item("date")
     title = RS.Fields.Item("title")
     body = RS.Fields.Item("body")
     user = RS.Fields.Item("user")
    
    response.write "<div class=""asset""><strong>"& title & "<br><br><strong>"& date & "- by </strong>"& user &"<br><br>"& body &"</div>"
    RS.movenext()
    wend
    end if
    %>
    <%
    RS.close
    set RS = nothing
    Conn.close
    set Conn = nothing
    %>
    now with blog, click here

  5. #5
    Sweet. IT WORKS!! ahah thanks alot. this is my first asp project, and its working!

    Thanks SOOOO much.

    -Naaman

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012