Results 1 to 1 of 1

Thread: random database result return asp

  1. #1
    Join Date
    May 2006
    Posts
    98
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default random database result return asp

    Hi, Anyone know how to adjust this so that the results appear in a random order? is it in the "Order By PostCardID DESC" part? could it be as simple as adding RND" instead od DESC?

    I just tried that and it throws up an error message.



    <!--#Include File="art/dbconnect.asp"-->
    <&#37;


    lngCategoryID=CLng(Request("CategoryID"))
    If lngCategoryID <> "" And lngCategoryID <> 0 Then

    Set connPostCardSoft=Server.CreateObject("ADODB.Connection")
    connPostCardSoft.Open PostCardSoftConnectString
    Set rsCard=Server.CreateObject("ADODB.Recordset")
    rsCard.CursorLocation = 3
    SQLQuery="Select PostCardID,DefaultHeadline,CardDescription,Default Message,Author,ThumbnailURL,AdvancedCard,Thumbnail HTML From tblGreetingPostCards Where CategoryID=" & Clng(lngCategoryID) & " Order By PostCardID DESC"
    rsCard.Open SQLQuery, connPostCardSoft
    rsCard.PageSize = 200
    intPageCount = rsCard.PageCount

    If rsCard.EOF=True Then
    Response.Write "<p>No cards found in database for this category."
    Response.End
    End If
    End If

    'search feature
    If Request("SearchWord") <> "" Then
    strWd=Replace(Request("SearchWord"),"'","''")
    strSQL="Select PostCardID,DefaultHeadline,CardDescription,Default Message,Author, "
    strSQL=strSQL & " ThumbnailURL,AdvancedCard,ThumbnailHTML From tblGreetingPostCards Where Keywords Like '%" & strWD & "%' OR "
    strSQL=strSQL & " DefaultHeadline Like '%" & strWD & "%' OR "
    strSQL=strSQL & " CardDescription Like '%" & strWD & "%' OR "
    strSQL=strSQL & " Author Like '%" & strWD & "%' OR "
    strSQL=strSQL & " DefaultMessage Like '%" & strWD & "%' "

    Set connPostCardSoft=Server.CreateObject("ADODB.Connection")
    connPostCardSoft.Open PostCardSoftConnectString
    Set rsCard=Server.CreateObject("ADODB.Recordset")
    rsCard.CursorLocation = 3
    rsCard.Open strSQL, connPostCardSoft
    rsCard.PageSize = 200
    intPageCount = rsCard.PageCount
    End If

    strAddition="bgcolor=" & Chr(34) & Application("gcp_SearchPageBackgroundColor") & Chr(34)
    strCategoryBarFontColor=Application("gcp_SearchPageFontBarColor")
    strCategoryBarColor=Application("gcp_SearchPageBarColor")

    'Retrieve Category Name
    If lngCategoryID <> "" and lngCategoryID <> 0 Then
    Set rsCat=connPostCardSoft.Execute("Select * From tblGreetingCategories Where CategoryID=" & Clng(lngCategoryID))
    strCat="" & rsCat("CategoryName")

    If rsCat("CategoryBackgroundImage")<> "" Then
    strAddition="background=" & Chr(34) & rsCat("CategoryBackgroundImage") & Chr(34)
    End If
    If rsCat("CategoryBackgroundColor")<>"" Then
    strAddition="bgcolor=" & Chr(34) & rsCat("CategoryBackgroundColor") & Chr(34)
    End If
    strCategoryBarFontColor=rsCat("CategoryBarFontColor")
    strCategoryBarColor=rsCat("CategoryBarColor")
    FontName=rsCat("FontName")
    FontColor=rsCat("FontColor")
    Else
    strCat="Search results for:" & strWD
    FontName=Application("gcp_FontName")
    FontColor=Application("gcp_FontColor")
    End If


    Select Case Request("Action")
    case " << "
    intpage = 1
    case " < "
    intpage = Request("intpage")-1
    if intpage < 1 then intpage = 1
    case " > "
    intpage = Request("intpage")+1
    if intpage > intPageCount then intpage = IntPageCount
    Case " >> "
    intpage = intPageCount
    case else
    intpage = 1
    If Request.QueryString("intpage") <> "" Then
    intpage=Request.QueryString("intpage")
    End If
    end select



    %>
    .. asp


    Thanks
    Richard
    Last edited by rich1234; 07-31-2007 at 04:11 PM. Reason: new idea

Bookmarks

Posting Permissions

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