homepage Welcome to WebmasterWorld Guest from 54.226.180.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
does getrows not do what i think then?
natty




msg:952969
 11:08 am on Feb 4, 2005 (gmt 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..

aRecords=oRS.GetRows(rows,start,fields)

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")
oConn.ConnectionString=application("ConnectionString")
oConn.Open

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)
else
'no recs
end if

BUT....
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?

tia

nat

 

Dreamquick




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

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

Rows
Optional. A GetRowsOptionEnum value that indicates the number of records to retrieve. The default is adGetRowsRest.
Start
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.
Fields
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 Recordset.Move before you fire off a GetRows call work?

- Tony

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

natty




msg:952971
 2:49 pm on Feb 9, 2005 (gmt 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.

mattur




msg:952972
 3:13 pm on Feb 9, 2005 (gmt 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...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved