Forum Moderators: open

Message Too Old, No Replies

New to ASP but have specific questions

wish to add latest sites and site of the day to site.

         

chompy

2:55 pm on Apr 9, 2003 (gmt 0)

10+ Year Member



Hi ASP Forum,

I'm busy endeavouring to learn ASP and with book in one hand and brain in the other i'm try to get the two to hit it off.

background:

My site is a directory of other sites i have written. At the moment all is in HTML not ASP. So i have now written a database with all the site titles a description, ID, photo url and url listof the site and category. And at the moment i can successfully add various fields from the database in the index page and call the images etc.

This is what i want to do:

1)I want to list the last 3 recently added sites to the page. 2)I wish to have a sequential daily change of site of the day. i.e starting from record 1 in the database it displays the selected record and links to one of the sites within my site - this then changes daily. 3)I also wish to have a section on the index page that shows a daily canging site from one particular category only.4)I want to link from these dynamic listed details to the html page of the relevant site.

my questions are;

A) I have managed so far to get the index page to show the various datafields but i am utilising 3 recordsets which have added to the size of the page and from reading they slow down the site. For point 1) the recordset sorts ascending. For point 2) it a recordset sorts descending and for point 3) the recordest filters to limit it to a particular type of data.
I am aware that there is a method to have multiple recordsets would this help in this situation as I am calling the same table baiscally.
Where do i look to find a simple explanation as to whether this is possible and a simple-ish explanation how to!?

B) AS I wish the site to show a a different site of the day for each new day i have to pass a variable? back to the server to tell it to access the next record, and when it reaches the last record to start over again. Any pointers as to where i can get some direct info on this aspect?

C) As I wish to call a html page and not a .asp generated page how do i get the eg. site of the day to link to its html page? Is it possible? and of course the link will change daily in the case of the site of the day.

I think that covers my query, sorry for the long post. I did read through and found these previous posts which i shall look up.

[webmasterworld.com...]

[webmasterworld.com...]

regards

jules

ziggystardust

8:16 am on Apr 10, 2003 (gmt 0)

10+ Year Member



A) Since you have multiple queries that won't be changing all too many times a day, you might want to consider caching that page.

One way of doing this is saving each of the sql-query results in a textfile which you include on the main page. Then just update that file whenever someone adds a site to your directory.

So instead of accessing the database every time someone visits your page, they'll see the data from the textfile.

If you don't want to use caching, there are a couple of other ways to speed up SQL-queries and recordsets in ASP.
For example, use the cachesize property with your recordset before executing the SQL and make sure you always use the appropiate cursor and locktypes.
Use getRows() to load your records into an array instead of accessing the DB.

sqlLast3 = "SELECT TOP 3 desc, url, dateadded FROM sites ORDER BY dateadded"

set rsLast3 = Server.CreateObject("Adodb.RecordSet")

rsLast3.CacheSize = 3 
[i]'get all 3 rows in a swoop, with cachesize, you should always aim to get just as many rows as you'll need, to minimize the number of DB-accesses[/i]

rsLast3.open sqlLast3, yourConnectionString, 0, 1 
[i]'the 0 is the forward-only cursor, and the 1 is the read-only lock type. These two are the fastest ones. Do a search on "ADO constants" to see all different types[/i]

arrResults = rsLast3.getRows()
[i]'This loads the recordset into a normal, two dimensionary array[/i]

rsLast3.close
set rsLast3 = nothing
[i]'Close the recordset and do the rest of your work on the array instead[/i]

B) Do you know which site of the day you want to show, or will this be random?

Sticky me if you have any questions.

//ZS