Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Location
    Northumberland, England
    Posts
    11

    Unanswered: Simple Question - iterating through a RecordSet

    Hi All,

    I'm trying to code an app in ASP-Vbscript and I want to get some values out of a simple 2 column table from the database.

    This is the code I have so far:

    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open (Server.MapPath("../data/gradDB.mdb"))

    set rs = Server.CreateObject("ADODB.recordset")

    rs.CursorType = 3 'adOpenStatic

    rs.open "select * from answers",conn

    dim answerArray
    answerArray = rs.GetRows(-1,1) 'does this need to be (-1,1)
    rs.close

    function answerCheck()
    'answer check

    dim finalAnswer

    for i = 0 to UBound(answerArray)
    Response.write(answerArray(arrayElement,1)&"<br>")
    next

    answerCheck = finalAnswer
    end function

    answerCheck
    %>

    Also does anyone know of any decent tutorials about cursor types, locations and lock types, I didn't find the content on w3schools to helpful, and i'm not too clear on these things.

    Many Thanks,
    Richard

  2. #2
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    answerArray = rs.GetRows(-1,1) 'does this need to be (-1,1)
    I usually use with no parameters and it works fine:
    answerArray = rs.GetRows

    Table Database Display via GetRows by Charles Carroll
    http://www.learnasp.com/learn/dbtablegetrows.asp

    Also does anyone know of any decent tutorials about cursor types, locations and lock types, I didn't find the content on w3schools to helpful, and i'm not too clear on these things.
    Cursor & LockType Performance Report - 6/27/1999
    http://www.4guysfromrolla.com/webtec...3.report.shtml
    Test was done for inserting recs instead of just getting them.
    Use adOpenForwardOnly cursor type (the default) whenever possible for speed, but use adOpenStatic if want to use objRS.MovePrev or objRS.RecordCount.
    Use adLockReadOnly lock type (the default) whenever possible for speed, but use adLockOptimistic when updating and deleting or adLockPessimistic if leaving a recordset open for editing which of course one shouldn't do on the Web anyway.
    [JPS Note: This article didn't say it but use adOpenKeyset cursor type (and probably adLockOptimistic lock type) if adding a new record and will be wanting to get the autonumber. The adOpenKeyset instead of adOpenForwardOnly cursor type may not be needed for a DSN-less connection but definitely IS needed for a DSN connection so might as well always use it if adding a new record and will be wanting to get the autonumber.]
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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