Results 1 to 2 of 2

Thread: So close! but yet so far away...

Threaded View

  1. #1

    Thread Starter
    Member shamloo's Avatar
    Join Date
    Oct 2000
    Location
    Stockholm, Sweden
    Posts
    32

    So close! but yet so far away...

    background:
    A few days ago, I started the thread "pageSize without RecordSet - is it possible ??" and claimed I had a working solution.
    I thought I did have one but oh, I was wrong

    The problem:
    I need to compare 2 dates, but it won't work for some reason. I've read that one should convert the dates to strings (example Cstr(myDatehere)) but even that won't work.
    I also know that when you're working with Access as your database, you should use '#' before and after the dates but since the Board Im making will be built on a SQL-server in the end I do NOT want to use access specific code.
    There must be a general(non database-specific) way to do this, right !?

    I've attatched a screenshot of my database so it's easier for you to help, if you decides to do so
    Here's my code-snippet:
    Code:
    IF (Page=false) THEN page=1
    Forum = Trim(Request.QueryString("Forum"))
    IF (pageSize=false OR pageSize >100) THEN pageSize=5
    
    IF (page >1) THEN
    	strSQL="SELECT TOP "& pageSize &" (SELECT Forums.Threads FROM Forums WHERE Forums.ID="& Forum &") AS ThreadsCount,"&_
    		   "Threads.ID,Threads.Title,Threads.Author,Threads.LastPostDate,Threads.Status,Threads.DatePosted, Threads.Replies, "&_
    		   "(SELECT Users.UserName FROM Users WHERE Users.ID=Threads.Author) AS ThreadAuthor "&_
    		   "FROM Threads WHERE Threads.Forum="& Forum &" AND Threads.LastPostDate < (SELECT Threads.LastPostDate FROM Threads WHERE Threads.LastPostDate < "& Cstr(""&"(SELECT Threads.LastPostDate FROM Threads WHERE Threads.ID="& int((page*pagesize)-pageSize)-1 &")"&"") &") ORDER BY Threads.LastPostDate DESC"
    ELSE
    	strSQL="SELECT TOP "& pageSize &" (SELECT Forums.Threads FROM Forums WHERE Forums.ID="& Forum &") AS ThreadsCount,"&_
    		   "Threads.ID,Threads.Title,Threads.Author,Threads.LastPostDate,Threads.Status,Threads.DatePosted, Threads.Replies, "&_
    		   "(SELECT Users.UserName FROM Users WHERE Users.ID=Threads.Author) AS ThreadAuthor "&_
    		   "FROM Threads WHERE Threads.Forum="& Forum &" ORDER BY Threads.LastPostDate DESC"
    END IF
    what Im trying to do here is to fetch posts XX from the database, and then if page is > 1, get the date of the last post on previous page, so the script knows where to start on page 2.
    Im I clear enough? if not I can upload my whole database along with the page.

    an example of the text above)
    * display the first xx posts(page one):
    topic 1
    topic 2
    topic 3
    ...
    topic xx

    * display next xx posts(page two):
    then the script needs to know where to start, I get this by getting the date of the last post on prev. page: int((page*pagesize)-pageSize)-1.
    page = which page you're viewing
    pagesize = how many topics/page you want to display.



    All help is highly appreciated !

    thanks,
    David
    Attached Images Attached Images  
    "There are no must's in life unless you provide for someone else than yourself"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width