If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Simple Question - iterating through a RecordSet

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-05, 07:32
daffy_dowden daffy_dowden is offline
Registered User
 
Join Date: Jan 2004
Location: Northumberland, England
Posts: 11
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
Reply With Quote
  #2 (permalink)  
Old 09-22-05, 14:49
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Quote:
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

Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On