Stepping backward through a query

This is a discussion on "Stepping backward through a query" within the Classic ASP section. This forum, and the thread "Stepping backward through a query are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 27th, 2005, 16:38
Junior Member
Join Date: Aug 2004
Location: United Kingdom
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Stepping backward through a query

Hello!

Just wading through a university assignment and i have come accross a problem, i am sure you guys will spot the problem straight away, i need to step backwards through the recordset of a query

any ideas welcomed,,, thanks

this is the code

<%
dim adOpenForwardOnly, adLockReadOnly,adCmdTable
adOpenStatic=3
adLockReadOnly =1
adCmdTable=2

dim objConn, objRS, objCommand
set objCommand = Server.CreateObject("ADODB.Command")
set objConn=Server.CreateObject("ADODB.Connection")
set objRS=Server.CreateObject("ADODB.Recordset")
objRS.CursorType=adOpenStatic

objCommand.ActiveConnection= strConnect
objCommand.CommandText= "piccomments"
objCommand.CommandType= adCmdTable
set objRS = objCommand.Execute

set objCommand=Nothing

Response.Write PicsToTable(objRS)

objRS.Close
Set objRS = Nothing
Set objConn = Nothing

%>

  #2 (permalink)  
Old Apr 27th, 2005, 16:52
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Looking for these?

ObjRS.MoveFirst
ObjRS.MovePrevious
ObjRS.MoveNext
ObjRS.MoveLast
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #3 (permalink)  
Old Apr 27th, 2005, 18:32
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Make sure you have the right cursor type. I've no idea though because I never use open recordsets. Too slow.
  #4 (permalink)  
Old Apr 27th, 2005, 18:38
Junior Member
Join Date: Aug 2004
Location: United Kingdom
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
What I want to do is skip to the end of the recordset

objRS.MoveLast

and then read them out backwards

objRS.MovePrevious

until BOF=true

but it says that i cannot go in reverse, i can do it with objRS.open but not objCommand.Execute

what is the faster alternative to recordsets?
  #5 (permalink)  
Old Apr 27th, 2005, 18:56
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Disconnected recordsets is what you are after.

Let me see if i can find my code library.....
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #6 (permalink)  
Old May 3rd, 2005, 09:01
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Quote:
Originally Posted by D3mon
Make sure you have the right cursor type. I've no idea though because I never use open recordsets. Too slow.
I've had this big issu in my head for ages!
if you don't use open recordsets, then what do you use?

do you save the recordsets as files and then re-open them? is that faster?

ps.: I know it's a bit out of topic but I really wanna know!!!!!!!!!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #7 (permalink)  
Old May 3rd, 2005, 11:45
New Member
Join Date: Apr 2005
Location: London
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to renegade
as Rob quite rightly pointed out Disconnected Recordsets are the best thing to use for this scenario.

There is a useful article on Disconnected Recordsets here http://www.4guysfromrolla.com/webtech/080101-1.shtml which describes it a lot better than I could
  #8 (permalink)  
Old May 3rd, 2005, 11:57
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
just what I thought.

so you can disconnect the recordset once it's been loaded and still access the information retrieved...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #9 (permalink)  
Old May 7th, 2005, 22:47
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
why not just use GetRows() to put the recordset into an array then step through the array bottom-to-top?
  #10 (permalink)  
Old May 9th, 2005, 12:02
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
getrows() wouldn't work for me because I still want to use some of the features of the recorset object: RecordCount, PageSize, PageCount, Filter, etc.
so disconnecting is a better idea...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #11 (permalink)  
Old May 9th, 2005, 23:31
Junior Member
Join Date: Aug 2004
Location: United Kingdom
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
As with any of the programming i have ever done, i get to a point and then realise i could do the whole lot better if i could be bothered to rewrite it all.

I will just use a SQL statement to order by reverse date. Its for diary type entries. So this also means i wont have to add them in any particular order.

Thanks anyway
Closed Thread

Tags
stepping, backward, through, query

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nav bar query Scottie Starting Out 10 Jun 9th, 2008 21:23
query about my $query ziggi PHP Forum 9 Aug 10th, 2007 14:05
MySQL query query dangergeek Databases 3 Apr 12th, 2007 12:45


All times are GMT. The time now is 23:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43