RcrdSet.MoveLast

L

le0

Hello guys,

I have this little problem in query, i queried one table and sort this
record in descending order but when I declared the recordset to move in the
last record but the browser rerurns an error called "Rowset does not support
fetching backward", but when I set the record to move in the first record
the browser returns the value I want. What does the error means?

code:

rstTSAnalysis.MoveLast
intItem = int(rstTSAnalysis.Fields("ItemNo").Value)

Response.Write intItem

Leo :)
 
B

Bobbo

le0 said:
I have this little problem in query, i queried one table and sort this
record in descending order

Can you not change the underlying SQL query instead? Your database is
probably more efficient at sorting a recordset than ASP.
 
B

Bob Barrows [MVP]

le0 said:
Hello guys,

I have this little problem in query, i queried one table and sort this
record in descending order but when I declared the recordset to move
in the last record but the browser rerurns an error called "Rowset
does not support fetching backward", but when I set the record to
move in the first record the browser returns the value I want. What
does the error means?
code:

rstTSAnalysis.MoveLast
intItem = int(rstTSAnalysis.Fields("ItemNo").Value)

Response.Write intItem
The problem is likely to be caused by the code you did not show us: cursor
type has a great deal to do with whether or not commands like MoveLast,
FoveFirst, etc. can work. The technique used to open your recordset has a
great deal to do with the cursor type used. The default cursor type is
forward-only: if you open a server-side (default - this cursor location is
specified by the constant adUseServer) recordset without specifying a cursor
type, you will get a forward-only cursor. If you specify adUseClient
(client-side cursor) for the recordset's CursorLocation property, you will
always get a static cursor (adOpenStatic), regardless of which type you may
have specified for the CursorType. Unless you specify these properties at
the Connection level (the Connection object has these properties as well as
the recordset), using Execute to open a recordset will result in the default
server-side, forward-only cursor.

Depending on the Provider being used, support for these navigational
commands can vary. Some providers will not suppport any navigation beyond
MoveNext if a default forward-only cursor is used. If you really require the
extra navigational commands (and I am not convinced that you do - it seems
to me a GetRows array would server your purposes handily), then you need
most likely need to use a more expensive static cursor (at the least). You
can guarantee that you get a static cursor by instantiating a recordset
object, setting its CursorLocation to adUseClient (3), and using its Open
method to open it, rather than using Execute.

The ADO documentation (as well as documentation for all MS development
technologies) can be found here:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoapireference.asp
I suggest you go there and _study_ the topics I discussed.

Help with GetRows can be found here:
http://www.aspfaq.com/search.asp?q=GetRows&type=ALL&category=0&numDays=0&order=1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top