SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help me......

    i currently doing a project using asp with vbscript. use database (SQL sever) to retrieve data from stored procedure and display on web. i now doing on sorting table. i have successfully sorting by type (about 8 columns). now i dont know how to do with to sort with ascending and descending. can anyone give me some guideline? thanks a lot.....

  2. #2
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    at the end of your code put

    order by column_name desc
    order by column_name asc

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    may b u think i so stupid, this such easy question dono how to do.....i still cant catch to do my program:
    part of the coding and two stored procedure involved:

    '***** retrieve Sorting Type from Store Procedure*****************
    set cmnSortTyp = server.CreateObject("ADODB.Command")
    set cmnSortTyp.ActiveConnection = DBWebCnn
    cmnSortTyp.CommandText = "sxrLogReportSelSortTyp"
    cmnSortTyp.CommandType = &H0004
    set rstSortTyp = server.CreateObject("ADODB.RecordSet")
    rstSortTyp.Open cmnSortTyp, ,0,1


    '================================================= ============================================ 'View Report Sorting Button .Click (Go Button) '================================================= ============================================ elseif (Request.Form("hidfrmViewLogRpt")="YES") then
    '**************************Sorting Record******************************************
    pageTitle = "View Reports"
    '***** retrieve Sorting Type from Store Procedure*****************
    set cmnSortTyp = server.CreateObject("ADODB.Command")
    set cmnSortTyp.ActiveConnection = DBWebCnn
    cmnSortTyp.CommandText = "sxrLogReportSelSortTyp"
    cmnSortTyp.CommandType = &H0004
    set rstSortTyp = server.CreateObject("ADODB.RecordSet")
    rstSortTyp.Open cmnSortTyp, ,0,1

    set cmnLogInfoSort = server.CreateObject("ADODB.Command")
    cmnLogInfoSort.Parameters.Append
    cmnLogInfoSort.CreateParameter("SortTyp",3,&H0001) 'adInteger
    cmnLogInfoSort.CreateParameter("typeName",200,&H0001,999) 'adVarChar,adInput
    cmnLogInfoSort.Parameters.Append cmnLogInfoSort.Parameters("SortTyp") = Request.Form("lstSortType")
    <select id="lstSortTyp" name="lstSortTyp">
    <option value="">Sorting By</option>
    <%rstSortTyp.movefirst
    while not rstSortTyp.eof%>
    <% if (Request.Form("hidfrmViewLogRpt")="YES") then %>
    <% if rstSortTyp("typ") = Request.Form("lstSortType") then %>
    <option value="<%=rstSortTyp("typ")%" selected><% =rstSortTyp("typName") %></option>
    <% else %>
    <option value="<%=rstSortTyp("typ")%" ><% =rstSortTyp("typName") %></option>
    <%endif%>
    <%else%>
    <option value="<%=rstSortTyp("typ")%" ><% =rstSortTyp("typName") %></option>
    <%endif%>
    <%rstSortTyp.movenext
    wend%>
    </select>
    Alter Procedure sxrLogReportSelSortTyp
    as
    select '1' typ, 'Lodge Date' typName
    Union
    select '2' typ, 'Request ID' typName
    Union
    select '3' typ, 'Exam Type' typName
    Union
    select '4' typ, 'Function' typName
    Union
    select '5' typ, 'Target' typName
    Union
    select '6' typ, 'Close Date' typName
    order by typName

    Alter PROCEDURE sxrLogReportSelBySort
    (
    @typ int

    )
    AS
    if @typ=1
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by logDt, requestID, examTyp, convert(char(20),panelTitle), userTyp, closeDt
    end
    else if @typ=2
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by requestID, logDt, examTyp, convert(char(20),panelTitle), userTyp, closeDt
    end
    else if @typ=3
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by examTyp, logDt, requestID, convert(char(20),panelTitle), userTyp, closeDt
    end
    else if @typ=4
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by convert(char(20),panelTitle), logDt, requestID, examTyp, userTyp, closeDt
    end
    else if @typ=5
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by userTyp, logDt, requestID, examTyp, convert(char(20),panelTitle), closeDt
    end

    else
    begin
    select requestID, logDt, examTyp, panelTitle, userTyp, followUpFlg, closeFlg, closeDt
    from xoLogReport
    order by closeDt, logDt, requestID, examTyp, convert(char(20),panelTitle), userTyp
    end

    return

    d coding quite long.....hope u understand what i write about....coz d program very long....n not in my problem scope....
    thanks a lot

  4. #4
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    may b u think i so stupid,
    never insinuated anything, this is a gentleman's forum

    I cant read through all your code, all i asked you to do is simply put the order by clause at the bottom of tht statement you want to order by descending or ascending e.g
    select * from users
    order by date_time desc

  5. #5
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry...i use this kind of word....just now i successfully solve d sorting table problem....i forgot to define parameter n pass d prameter to my program....thanks a lot...


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
  •