|
Home > Archive > IIS ASP > August 2006 > RcrdSet.MoveLast
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| 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 
| |
|
|
le0 wrote:
> 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.
| |
| Bob Barrows [MVP] 2006-08-24, 1:35 pm |
| le0 wrote:
> 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/e...pireference.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=...mDays=0&order=1
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
|
|
|
|
|