Question

How to page through a recordset one item at a time.

Asked by: lshane

DWMX
MS Access
WIN XP PRO
Classic ASP VBScript

Hello.  I'm trying to page through a recordset one item at a time, but I'm not sure how to do it.

I click on a thumbnail and it takes me to a "LargerImage" page.  From there, I would like to have NEXT and PREVIOUS buttons at the bottom to page through the recordset forwards and backwards... starting at the image that was just passed through the URL.

Please take a look at the URL (http://www.jasonkellytattoo.com/tattoos.asp) and click on a thumbnail.  Beginning at that particular image, I would like to page forwards and backwards through the recordset.  The recordset on the "LargerImage" page is basic and just displays whatever image that is equal to the URL parameter.

Your help is ALWAYS appreciated greatly!

Thank you,
Shane

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-03-06 at 21:41:52ID23222170
Tags

Classic ASP VBScript

,

IE6

,

http://www.jasonkellytattoo.com/tattoos.asp

Topic

Active Server Pages (ASP)

Participating Experts
2
Points
500
Comments
26

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. For Each item in Recordset
    I'm just starting out using ASP.net (VB.NET) and i'm trying to find an ASP.NET equivilant to this piece of code: set objrecs = server.CreateObject("ADODB.Recordset") set objConn = server.CreateObject("ADODB.Connection") objConn.open strConnect objRecs.op...
  2. recordset
    Can anyone show me code to show how the recordset object works in VB.net. I know that now everybody uses datasets, even i do, but i want to see how the code for recordset looks like.... question >> recordset is different than datareader? Moiz
  3. recordsets
    Hi, I am loading some values from a database into a recordset and looping through them to display them on a page. Is there anyway to perform mathmatic functions on the values in a recordset? Say for instance I am loading 10 values into the recordset, and I want to display...
  4. Recordset not being found
    I have a new page in DW MX2004 I created a recordset If I try to create a dynamic table from the menus, a message asks me for a recordset, which is already there but seemingly not recognised. If I place a textfield on the page and appply a repeat region SB, only one record ...
  5. Classic ASP VBScript:  Sessions
    Hello. I am using Classic ASP VBScript with MS Access. I have a user logging into a site. I have 2 login fields ("username" and "password"). The database, however, has 4 fields of {username, password, userFirst, userLast}. After the user logs into the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ryancysPosted on 2008-03-06 at 23:54:27ID: 21068136

I'm not too sure how you "sort" the images' order, however, you may try something like this to get the previous image and next image's id by using this query:

SELECT yourTable.*,
(Select top 1 id from yourTable as temp1 where id < yourTable.id order by id desc) as previousID,
(Select top 1 id from yourTable as temp2 where id > yourTable.id order by id) as nextID
 FROM yourTable
Where id = <currentID>

get the idea?

 

by: mgfranzPosted on 2008-03-07 at 07:20:07ID: 21070944

Your already passing the img ID through your main page, why make this more difficult?  Try this;

<%
imgID = Request("ImgID")
%>
<tr class="rslink">
    <td align="center"><a href="<%= "/largeimage.asp?"imgID - 1%> ">PREVIOUS</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="="<%= "/largeimage.asp?"imgID + 1%>">NEXT</a></td>
  </tr>

But why the database need?  Are you storing the imges in the dB?

 

by: lshanePosted on 2008-03-07 at 10:17:38ID: 21072846

Hello, mgfranz.  Thank you for your reply.  Your example looks very similar to the concept I had in my head, but I didn't know how to get there.  I have a couple of questions, before I attempt to implement:

1)  Should the "imgID = Request("ImgID")" you listed above be "request.querystring("ImgID")", since it is coming across the URL?

2)  The "ImgID" is just an "autonumber" of the database records.  Would the " -1 " and " +1 " matter if the record ID's are not incremented by "1"?   (i.e.  The first record ID may be "3" and the next may be "7" due to deletes, etc.).

Yes, images are stored in the database.


Thank you so much,
Shane

 

by: mgfranzPosted on 2008-03-07 at 10:54:45ID: 21073179

To try to answer your questions;

1)  Should the "imgID = Request("ImgID")" you listed above be "request.querystring("ImgID")", since it is coming across the URL?

Request("ImgID") and Request.Querystring("ImgID") are the same thing, QueryString is the default Request parameter.

2)  The "ImgID" is just an "autonumber" of the database records.  Would the " -1 " and " +1 " matter if the record ID's are not incremented by "1"?   (i.e.  The first record ID may be "3" and the next may be "7" due to deletes, etc.).

This will cause an issue, what you will probably have to do is to actually capture the ImgID, then when you write the previous and next buttons you will need to actually find the actual record in the dB, I am not sure what the best way to do this would be.  It might be possible to create an array using GetRows() to grab all the ImgID's that are in the dB then use this data to create a "previous record" an da "next record" querystring.  

 

by: lshanePosted on 2008-03-07 at 11:32:43ID: 21073504

Thanks, mgfranz.  I realized that I am actually sorting based on a date that is entered (A little manipulation so the user can order the images by "Newest", in case he has to delete).  Would this simplify matters?

 

by: mgfranzPosted on 2008-03-07 at 19:33:15ID: 21075781

Check out this page, you should be able to modify the code to work on one record at a time easily enough.  http://www.codefixer.com/codesnippets/recordsetpaging.asp

Look into what the RecordSet properties MoveNext and MovePrevious do, they should be able to solve your problem.  Basically what you need to do is pass the ImgID to a picture page and use it as your default SQL call, then build the MovePrevious() and MoveNext calls based on this value.  

 

by: lshanePosted on 2008-03-07 at 20:09:34ID: 21075863

YES!  That is exactly what I need to do (Regarding the passed value being my default SQL, or starting point, on the image page).  I was having a difficult time articulating my objective, but you summed it up.

I will look at the link and let you know.

Thanks so much!
Shane

 

by: ryancysPosted on 2008-03-07 at 22:02:03ID: 21076092

>> I realized that I am actually sorting based on a date that is entered (A little manipulation so the user can order the images by "Newest", in case he has to delete).  Would this simplify matters?

Have you try the query I posted above? try amend to something like this:

SELECT yourTable.*,
(Select top 1 id from yourTable as temp1 where yourDate < yourTable.yourDate order by yourDate desc) as previousID,
(Select top 1 id from yourTable as temp2 where yourDate > yourTable.yourDate order by yourDate) as nextID
 FROM yourTable
Where id = <currentID>

Will this help?

 

by: lshanePosted on 2008-03-07 at 22:57:36ID: 21076168

Hi, mgfranz.  I will definitely read those tomorrow.

Hi, ryancys.  Yes, I looked at your example, but it is still a little cryptic to me.  I'm not fluent in SQL, so I need a little extra assistance.  I mean, I see where I am to replace your placeholder fields with my actual Tables and Fields; but can I just Copy-and-Paste everything else As-Is, or are there some other syntax elements not shown?  I've never seen SQL syntax like what you have displayed; but then again, I haven't seen much at all outside of the basics of SQL.  If you could be as exact with your example as possible, that would help me greatly.  Also, bear in mind I am entering this in the SQL dialog box of DWMX.


Thanks so much,
Shane

 

by: ryancysPosted on 2008-03-08 at 00:23:55ID: 21076328

Perhaps you can let us know your table's structure and post your script here, so that we can try refer and amend from there.

 

by: lshanePosted on 2008-03-08 at 10:29:10ID: 21078081

Certainly ryancys.  Thank you.  I will attach the code from the "LargeImage" page.  It is a basic page, with a basic DWMX query to show the Larger Image of the "ID" being passed via the URL.  As mgfranz said above, my goal is to create a query that will let me view "Previous" and "Next" from whatever image is being displayed on the "LargeImage" page.  It just needs to be able to search for whatever the Previous, or Next, record is in the database.

Thank you so much,
Shane

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connjk.asp" -->
<%
Dim rsImageLarge__MMColParam
rsImageLarge__MMColParam = "1"
If (Request.QueryString("imgID") <> "") Then 
  rsImageLarge__MMColParam = Request.QueryString("imgID")
End If
%>
<%
Dim rsImageLarge
Dim rsImageLarge_numRows
 
Set rsImageLarge = Server.CreateObject("ADODB.Recordset")
rsImageLarge.ActiveConnection = MM_connjk_STRING
rsImageLarge.Source = "SELECT * FROM images WHERE imgID = " + Replace(rsImageLarge__MMColParam, "'", "''") + ""
rsImageLarge.CursorType = 0
rsImageLarge.CursorLocation = 2
rsImageLarge.LockType = 1
rsImageLarge.Open()
 
rsImageLarge_numRows = 0
%>
<html>
<head>
<title>Jason Kelly Tattoos and Paintings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="test/jkstyles.css" rel="stylesheet" type="text/css">
</head>
 
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" background="images/pageBG.gif">
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><img src="<%=(rsImageLarge.Fields.Item("imgLarge").Value)%>" border="0" align="absmiddle"></td>
  </tr>
  <tr>
    <td><hr></td>
  </tr>
  <tr>
    <td><strong><font color="#FFFFFF"><%=(rsImageLarge.Fields.Item("imgDesc").Value)%></font></strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr class="rslink">
    <td align="center"><a href="#">PREVIOUS</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#">NEXT</a></td>
  </tr>
</table>
</body>
</html>
<%
rsImageLarge.Close()
Set rsImageLarge = Nothing
%>
                                              
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:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:

Select allOpen in new window

 

by: ryancysPosted on 2008-03-09 at 00:58:17ID: 21080707

You can try something like this, but you still need amend accordingly (table name, date field name, etc)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connjk.asp" -->
<%
Dim rsImageLarge__MMColParam
rsImageLarge__MMColParam = "1"
If (Request.QueryString("imgID") <> "") Then 
  rsImageLarge__MMColParam = Request.QueryString("imgID")
End If
%>
<%
Dim rsImageLarge
Dim rsImageLarge_numRows
 
Set rsImageLarge = Server.CreateObject("ADODB.Recordset")
rsImageLarge.ActiveConnection = MM_connjk_STRING
 
SQLStr = "SELECT images.*, " & _
	"(Select top 1 imgID from images as temp1 where yourDate < images.yourDate order by yourDate desc) as previousID, " & _
	"(Select top 1 imgID from images as temp2 where yourDate > images.yourDate order by yourDate) as nextID " & _
	"FROM images " & _
	"Where imgID = " & rsImageLarge__MMColParam
 
rsImageLarge.Source = SQLstr
 
 
rsImageLarge.CursorType = 0
rsImageLarge.CursorLocation = 2
rsImageLarge.LockType = 1
rsImageLarge.Open()
 
//response, etc if no record was found
if rsImageLarge.eof then response.redirect "err.asp?msg=norecord"
 
rsImageLarge_numRows = 0
%>
<html>
<head>
<title>Jason Kelly Tattoos and Paintings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="test/jkstyles.css" rel="stylesheet" type="text/css">
</head>
 
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" background="images/pageBG.gif">
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><img src="<%=(rsImageLarge.Fields.Item("imgLarge").Value)%>" border="0" align="absmiddle"></td>
  </tr>
  <tr>
    <td><hr></td>
  </tr>
  <tr>
    <td><strong><font color="#FFFFFF"><%=(rsImageLarge.Fields.Item("imgDesc").Value)%></font></strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr class="rslink">
    <td align="center">
<% if isnumeric("" & rsImageLarge("previousID")) then %>
<a href="yourPage.asp?imgID=<%=rsImageLarge("previousID")%>">PREVIOUS</a>&nbsp;&nbsp;&nbsp;&nbsp; 
<% end if %>
<% if isnumeric("" & rsImageLarge("nextID")) then %>
<a href="yourPage.asp?imgID=<%=rsImageLarge("nextID")%>">NEXT</a>
<% end if %>
</td>
  </tr>
</table>
</body>
</html>
<%
rsImageLarge.Close()
Set rsImageLarge = Nothing
%>

                                              
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:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:

Select allOpen in new window

 

by: ryancysPosted on 2008-03-09 at 01:01:19ID: 21080714

>>try something like this, but you still need amend accordingly (table name, date field name, etc)

sorry, the table name is not need to change here as already been changed..

 

by: lshanePosted on 2008-03-14 at 17:05:06ID: 21130641

Hi, ryancys.  Sorry for the delay.  My hard drive crashed last weekend and I've spent all week installing another and reinstalling all my applications.  I'm just now going to be able to reconfigure all my sites tonight.  I hope to possibly try your latest suggestion(s) later tonight.

I'll let you know if that works OK.

(Guess I'll be "Ghosting" my HDD this time around).  :|

Thanks,
Shane

 

by: ryancysPosted on 2008-03-14 at 18:11:10ID: 21130902

No prob Shane, I hope we could make some helps here : )

 

by: lshanePosted on 2008-03-18 at 16:10:22ID: 21157080

Hi, ryancys.  I tweaked the fields to match mine and then had to tweak the "<" and ">" operators to achieve the desired "Previous" and "Next" functions.   I think we're almost there, but a couple of things are happening.

I have 2 thumbnail pages (tattoos.asp and paintings.asp).
One table that contains all images [images].
[images] also contains a foreign field for a "Category" type: {imgCat}.

When clicking a thumb from either of the 2 pages, it passes the "imgID" via the URL to the "largeimage.asp" page.

It was working fine when all had were images of one category type "1" in the table; HOWEVER, as soon as I added other images with a different category type "2" it gave me the following message:
=======================================================
Error Type:
Microsoft JET Database Engine (0x80004005)
At most one record can be returned by this subquery.
/jasonkelly/largeimage.asp, line 29
=======================================================
I have attached that code.  Line "29" is this:  "rsImageLarge.Open()"
I pasted Lines 1 - 36.

If I remove all images with one or the other category types (leaving only one type in the table), then it displays fine again.

I tried creating a separate page for the main image of "paintings" (using your same code), but it gives the same problem.  It's almost like if it sees more that one Category type in that table [images], it flags the error.

Any ideas?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connjk.asp" -->
<%
Dim rsImageLarge__MMColParam
rsImageLarge__MMColParam = "1"
If (Request.QueryString("imgID") <> "") Then 
  rsImageLarge__MMColParam = Request.QueryString("imgID")
End If
%>
<%
Dim rsImageLarge
Dim rsImageLarge_numRows
 
Set rsImageLarge = Server.CreateObject("ADODB.Recordset")
rsImageLarge.ActiveConnection = MM_connjk_STRING
 
SQLStr = "SELECT images.*, " & _
	"(Select top 1 imgID from images as temp1 where imgDate > images.imgDate order by imgDate) as previousID, " & _
	"(Select top 1 imgID from images as temp2 where imgDate < images.imgDate order by imgDate desc) as nextID " & _
	"FROM images " & _
	"Where imgID = " & rsImageLarge__MMColParam
 
rsImageLarge.Source = SQLstr
 
 
rsImageLarge.CursorType = 0
rsImageLarge.CursorLocation = 2
rsImageLarge.LockType = 1
rsImageLarge.Open()
 
//response, etc if no record was found
if rsImageLarge.eof then response.redirect "err.asp?msg=norecord"
 
 
rsImageLarge_numRows = 0
%>

                                              
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:

Select allOpen in new window

 

by: lshanePosted on 2008-03-18 at 17:30:38ID: 21157525

Hi, ryancys.  OK - I figured out the conflict.  All images are in the one table [images], but different Category types can be assigned to each image (i.e. "1" or "2", etc.).  However, since your query is based on DATE, if I have "3/1/2008" assigned for an image with a Category type of "1" and then have "3/1/2008" assigned to an image with a Category type of "2", it conflicts.

How can we tweak your code to work as it does, but additionally to only display based on the URL parameter of "imgCat"?

 

by: ryancysPosted on 2008-03-18 at 19:32:11ID: 21158039

Hi there,

How's your latest Query looks like? Can you post it here?

And can you list the fields in your table "images" ?

 

by: lshanePosted on 2008-03-18 at 20:02:50ID: 21158156

Hi, ryancys.  Thank you - you've been most helpful.  Yes, I'll post the info below:

1) Table [images] fields:  {imgID, imgLarge, imgCat, imgDesc, imgDate}
2) I will attach the snippet of the latest query.

I guess the tweak should pretty much accomplish the following:

The 2 pages "tattoos.asp" and "paintings.asp" have Category types of "1" and "2", respectively.

When clicking on the "tattoos.asp" page, there is a recordset that displays all records with an "imgCat" equal to "1" - and the same for the "paintings.asp" page displaying records with an "imgCat" equal to "2".

You click on a thumbnail and it takes you to the main "largeimage.asp" page where your query kicks in.
With the query you provided (attached), it allows the selected thumbnail to be the default image and then allows you to scroll "Previous" by DATE Descending and "Next" by DATE Ascending.

That works great, except when there is another record with the same DATE.  I tried changing all the "imgDate" fields to "imgID" to try the same thing, but in that instance, it scrolled through ALL the images --- whether Category "1" or "2".

I guess firstly the "Large Image" should be displayed based on the thumbnail selection from the previous page, and then should scroll "Previous" and "Next" with the added criteria of "imgCat".  I could just append the "imgCat=1" or "imgCat=2" to the thumbnail link and then do some kind of "request.querystring("imgCat")" query, or something, but I'm getting lost at that point.  I tried several things like that, but not quite achieving the goal.

Let me know if you need anything else from me.

Thanks so much!
Shane

<%
Dim rsImageLarge__MMColParam
rsImageLarge__MMColParam = "1"
If (Request.QueryString("imgID") <> "") Then 
  rsImageLarge__MMColParam = Request.QueryString("imgID")
End If
%>
<%
Dim rsImageLarge
Dim rsImageLarge_numRows
 
Set rsImageLarge = Server.CreateObject("ADODB.Recordset")
rsImageLarge.ActiveConnection = MM_connjk_STRING
 
SQLStr = "SELECT images.*, " & _
	"(Select top 1 imgID from images as temp1 where imgDate > images.imgDate order by imgDate) as previousID, " & _
	"(Select top 1 imgID from images as temp2 where imgDate < images.imgDate order by imgDate desc) as nextID " & _
	"FROM images " & _
	"Where imgID = " & rsImageLarge__MMColParam
 
rsImageLarge.Source = SQLstr
 
 
rsImageLarge.CursorType = 0
rsImageLarge.CursorLocation = 2
rsImageLarge.LockType = 1
rsImageLarge.Open()
 
//response, etc if no record was found
if rsImageLarge.eof then response.redirect "err.asp?msg=norecord"
 
rsImageLarge_numRows = 0
%>

                                              
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:

Select allOpen in new window

 

by: ryancysPosted on 2008-03-18 at 22:22:58ID: 21158698

Hi, you may try this:

<%
Dim imgID, imgCat

imgID = Request.QueryString("imgID")
imgCat = Request.QueryString("imgCat")

Dim rsImageLarge
Dim rsImageLarge_numRows
 
Set rsImageLarge = Server.CreateObject("ADODB.Recordset")
rsImageLarge.ActiveConnection = MM_connjk_STRING
 
SQLStr = "SELECT images.*, " & _
        "(Select top 1 imgID from images where imgID < " & imgID & " and imgCat = " & imgCat & " order by imgID desc) as previousID, " & _
        "(Select top 1 imgID from images where imgID > " & imgID & " and imgCat = " & imgCat & " order by imgID)  as nextID " & _
        "FROM images " & _
        "Where imgID = " & imgID

rsImageLarge.Source = SQLstr
 
 
rsImageLarge.CursorType = 0
rsImageLarge.CursorLocation = 2
rsImageLarge.LockType = 1
rsImageLarge.Open()
 
//response, etc if no record was found
if rsImageLarge.eof then response.redirect "err.asp?msg=norecord"
 
rsImageLarge_numRows = 0
%>



then your hyperlink should be something like:

yourpage.asp?imgID=5&imgCat=2

this query order by imgID now, however think it's not perfect solution, but this should able to resolve your problem.

 

by: lshanePosted on 2008-03-19 at 15:24:36ID: 21166508

Hi, ryancys.  Yeah - this does still create a problem.  I guess the only way to truly use your first solution and avert this problem is to just have 2 tables:  [tattoo_images] and [painting_images] and just insert the images accordingly in the INSERT forms.

Your first solution worked great by DATE, but the Category issue was causing a problem.  Since the client will only have the 2 Categories, having 2 tables seems like a simple solution.

Would that sound logical to you?

 

by: ryancysPosted on 2008-03-19 at 19:19:09ID: 21167666

In fact, I tested above and it should works.. at least for my test database..

>>Would that sound logical to you?
Your images data should reside in a single table..

can you post a copy of your database somewhere on internet, so that we can refer to it? or you can email (zipped) directly to me (you can find my email from my profile..)

 

by: lshanePosted on 2008-03-20 at 23:46:10ID: 21178499

Hi, ryancys.  Thank you.  I zipped and E-mailed the database to you.

Thank you,
Shane

 

by: lshanePosted on 2008-03-21 at 19:56:21ID: 21184590

Hi, ryancys.  I went ahead and awarded the points because your solution accomplished the goal 100%.

I know typically I would have all images in one table, but for this one, since these are the only 2 categories the client will have, this was a simple solution and I just modified and applied your solution to 2 separate pages, as opposed to one... and it works great.

Thanks so much,
Shane

 

by: ryancysPosted on 2008-03-24 at 20:08:09ID: 21199243

Hi Shane,

try a statement like this.. this works for me..


SQLStr = "SELECT images.*, " & _
 "(Select top 1  imgID from images a where imgID <  images.imgID and imgCat = images.imgCat order by imgID desc ) as previousID, " & _
 "(Select top 1  imgID from images b where imgID >  images.imgID and imgCat = images.imgCat order by imgID ) as nextID " & _
"FROM images Where imgID = " & imgID

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...