Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

does getrows not do what i think then?

11:08 am on Feb 4, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Mar 7, 2003
votes: 0

hi all,

i posted a question not long ago about getrows, which altho i know is not the preffered method of paging (over stored procs..)
but having looked at the usage i find the follwing..


rows = value that specifies the number of records to retrieve.
start = Optional. What record to start on, a record number or a BookmarkEnum value
fields = Optional. If you want to specify only the fields that the GetRows call will return, it is possible to pass a single field name/number or an array of field names/numbers in this argument

and i am trying to use getrows liek this

set oConn=server.CreateObject("ADODB.Connection")
set oRS=server.CreateObject("ADODB.Recordset")

q="EXEC usp_getCodes"

oRS.Open q, oConn, 3, 1, 1
'i am told i need adOpenStatic - 3 for this to work

startRec = 10
numnPerPage = 15

if not (oRS.EOF or oRS.BOF) then
aRecs = oRS.GetRows(numPerPage, startRec)
'no recs
end if

what actually happens is the following (and yes there are recs to return)

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/admin/codeinfo_test.asp, line 26

line 26 being the aRecs = oRS.getRows(x,y) line
btw in case it matters, using sql server as db

any ideas?



1:47 pm on Feb 7, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 25, 2002
votes: 0

Reading the documentation [msdn.microsoft.com] for GetRows...

Optional. A GetRowsOptionEnum value that indicates the number of records to retrieve. The default is adGetRowsRest.
Optional. A String value or Variant that evaluates to the bookmark for the record from which the GetRows operation should begin. You can also use a BookmarkEnum value.
Optional. A Variant that represents a single field name or ordinal position, or an array of field names or ordinal position numbers. ADO returns only the data in these fields.

Never played with the Start param of GetRows but it looks like your problem might be that "Start" doesn't do quite what you think it does (in that it seems to expect a bookmark value rather than a literal).

I'd try removing your "start" variable then checking if it works - if it does then there's your culprit.

As an alternative would calling a

before you fire off a
call work?

- Tony

Also might just be a posting typo, but you're calling the variable "numnPerPage" when you set it but then "numPerPage" in the call.

2:49 pm on Feb 9, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Mar 7, 2003
votes: 0

hi Dreamquick,

thanks for the reply.
yes, as the name of the topic sugegsted, i figured i was misunderstanding something.

for me getrows is all about not having to mess with cursors and movenext type actions. saving time and load, even if it leaves code not especially readable.

removing the start variable, would somewhat kill the whole idea, being as i am trying to use this for paging, and its not much good if i cant specify which record to start on.

the explanation i got of getrows was from w3schools, and im not so 'au fait' with the whole cursor thing, i will try the oRS.move before the call, as like you say, its seems the start is the problem, so if i can set that with a move, then grab all that remains (or actually the numPerPage amount more records) with getrows, i may be away :)

ps. yes the typo was purely on here.

3:13 pm on Feb 9, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 29, 2002
votes: 0

You could handle the paging in your asp code, using GetRows to just return an array of all the records in the query. IME this will still give your pages a performance boost over recordset-based paging.

Using start and num of records with GetRows will not neccessarily speed up your page, as the database/ADO still has to run the whole query, then do some additional jiggery-pokery to narrow this resultset down to a subset of records. YMMV...