Skip to main content
Participant
July 16, 2006
Question

Random Image Path Static on Delivery of Page

  • July 16, 2006
  • 2 replies
  • 273 views
Goal: To generate 6 random images on a webpage using the image path to the server and provide a link to the website of all of the images.

Background:
The images are on our server and a record is created for each in an MS Access database.

The records contain:
Record ID (autonumber)
Name
Path to Server
Path to Images’ Website
More..

Created a query that generates random records:
--
SELECT TOP 4 tblOutsideLinks.LinkName, tblOutsideLinks.AdroitServerLocation, tblOutsideLinks.WebsiteLink, tblOutsideLinks.ContactName, tblOutsideLinks.ContactEmail, tblOutsideLinks.LinkNo
FROM tblOutsideLinks
ORDER BY Rnd([LinkNo]) DESC;
--

This works fine. Even though it isn’t truly random I am okay with the results.

I created a recordset query in Dreamweaver using the query and when testing the results using the button in the recordset dialogue they show the same results as the MS Access Database.

I tried to display the results on an asp page and they are static.

I started reading posts (dozens of them) to try to figure the issue out, but no one seems to be doing the same thing so I extracted the rand functions and created a random variable before the sql is run on the page. I then incorporated the variable in the dialogue window and tried to let it run. I can see the variable changing on the page, but the records are still static.

I also played with the cursortype and some other things, but nothing appears to get this train moving.

When I get the random records I would like to attach each one to an image using the record source function. I tested this method before going to the random records and it works quite nicely.

I would be happy to supply any other information or code you may need, but as you can tell I am a novice, so I am not so sure what else you would need.

Thanks for the help,
Keith

BELOW IS SECTIONS OF PAGE CODE

<%
RANDOMIZE
Dim rsRandomNumber
rsRandomNumber =(INT((6)*RND()))
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_adroit_STRING
Recordset1.Source = "SELECT TOP 4 tblOutsideLinks.LinkName, tblOutsideLinks.AdroitServerLocation, tblOutsideLinks.WebsiteLink, tblOutsideLinks.ContactName, tblOutsideLinks.ContactEmail, tblOutsideLinks.LinkNo FROM tblOutsideLinks ORDER BY Rnd([LinkNo]) DESC;"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
This topic has been closed for replies.

2 replies

Inspiring
February 6, 2007
Certainly sounds like a caching issue. You could add a no-cache instruction
in the header to the page.

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"boycetrus" <webforumsuser@macromedia.com> wrote in message
news:eq91sm$jc4$1@forums.macromedia.com...
>I seem to be having the same problem. I'm trying to present a random image
>on
> the home page of a site from a series of about 1600 records in a database.
>
> I'm using MS Access and VBScript. I have successfully created an sql query
> in
> the database and the code on the page (I've tried both ways - ie. by
> creating a
> separate table in the database and also embedding the query in the asp
> code).
>
> Each time I evaulate the query in the database or test it in the recordset
> creation dialogue it the result is different so I know the query works.
> But
> once I've uploaded the page to the server the query doesn't seem to be
> re-evaulated when the page is reloaded. It originally retrieved a random
> image
> but the image has not changed.
>
> I'm thinking some sort of server caching issue?
>
> Any suggestions?
>


Participant
February 6, 2007
I seem to be having the same problem. I'm trying to present a random image on the home page of a site from a series of about 1600 records in a database.

I'm using MS Access and VBScript. I have successfully created an sql query in the database and the code on the page (I've tried both ways - ie. by creating a separate table in the database and also embedding the query in the asp code).

Each time I evaulate the query in the database or test it in the recordset creation dialogue it the result is different so I know the query works. But once I've uploaded the page to the server the query doesn't seem to be re-evaulated when the page is reloaded. It originally retrieved a random image but the image has not changed.

I'm thinking some sort of server caching issue?

Any suggestions?