ORDER BY clause in asp.net dataset

Ask a Question related to Adobe Dreamweaver & Contribute, Design and Development.

  1. #1

    Default ORDER BY clause in asp.net dataset

    I have an aspx page on which is a dataset created in DWMX. The sql query is
    described in the line CommandText='<%# 'SELECT * FROM booklist ' %>' I want
    to be able to sort the list and the consequent page in different ways
    dynamically. In classic ASP I would do this by passing a querystring back to
    the page (like pasge.asp?sortorder=id) and it was easy to fix the querystring
    to accept a parameter. But in .net I cant do this, I have tried adding a
    parameter in the MX query-invoking dialog but the result CommandText='<%#
    'SELECT * FROM booklist ORDER BY @sortorder' %>' - although it tests
    correctly in the dialog - once sent and tested on the server produces an SQL
    server message saying that I must supply a column name in order to be able to
    use ORDER BY. (but I am !!) I can use CommandText='<%# 'SELECT * FROM
    booklist ORDER BY ' + request.querystring('sortorder') %>' , that works but of
    course falls over if the page is called without the querystring. Can anyone
    help me in re-sorting a datalist dynamically?

    davidxtaylor Guest

  2. Similar Questions and Discussions

    1. Re-arranging order of DataSet
      Is it possible to re-arrange the order of the dataset, not just sort it. If you have a look at: http://www.ducksoupdesign.net/tak/stock/ You...
    2. Strange results of ORDER BY clause when item begins with slash orbackslash
      I am seeing some unexpected results for an ORDER BY in a query. It looks to me as if the sorting is confused about how to handle the slash or...
    3. Where Clause: Order of Precedence
      Here's my WHERE clause on an SQL statement I wrote: WHERE blnLive = TRUE AND blnVacPromo = TRUE AND (dtToPost <= Now() AND dtToRemove > Now() ) ...
    4. Trouble with ORDER BY clause
      Hi all I'm not sure ASP is the problem, but my SQL statement seems fine to me. This works fine : strSQL = "SELECT .* FROM _RechPat INNER JOIN...
    5. ORDER BY clause causes read-only recordset
      I have a website with some asp pages running off of a MS Sql db. For reasons that I can't explain, whenever querying the database with a SELECT...
  3. #2

    Default Re: ORDER BY clause in asp.net dataset

    Hi

    I had exactly the same problem with a site I did last year
    (pharmacyhealthlink.org)
    Basically I did something like this, checked to see if param was available
    and if not set a default

    <script runat="server>
    dim mySortOrder
    dim myCmd

    sub page_load

    if Request.Params("sortorder") = "" then
    mySortOrder = "ASC"
    else
    mySortOrder = Request.Params("sortorder")
    end if

    myCmd = "Select * from booklist Order By " + mySortOrder
    end sub
    </script>

    And then
    CommandText='<%# myCmd %>'

    Hope this helps


    "davidxtaylor" <webforumsuser@macromedia.com> wrote in message
    news:cv7k9h$q9a$1@forums.macromedia.com...
    >I have an aspx page on which is a dataset created in DWMX. The sql query is
    > described in the line CommandText='<%# 'SELECT * FROM booklist ' %>' I
    > want
    > to be able to sort the list and the consequent page in different ways
    > dynamically. In classic ASP I would do this by passing a querystring back
    > to
    > the page (like pasge.asp?sortorder=id) and it was easy to fix the
    > querystring
    > to accept a parameter. But in .net I cant do this, I have tried adding a
    > parameter in the MX query-invoking dialog but the result CommandText='<%#
    > 'SELECT * FROM booklist ORDER BY @sortorder' %>' - although it tests
    > correctly in the dialog - once sent and tested on the server produces an
    > SQL
    > server message saying that I must supply a column name in order to be able
    > to
    > use ORDER BY. (but I am !!) I can use CommandText='<%# 'SELECT * FROM
    > booklist ORDER BY ' + request.querystring('sortorder') %>' , that works
    > but of
    > course falls over if the page is called without the querystring. Can
    > anyone
    > help me in re-sorting a datalist dynamically?
    >

    ossie Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139