Dynamic Sorting

Results 1 to 3 of 3

Thread: Dynamic Sorting

  1. #1
    Raymond Guest

    Default Dynamic Sorting

    I want to allow the user to sort the table by clicking on the field name (table header). This is what I have come up with and I keep getting an error message.<BR><BR>&#060;%<BR> SortBy = request.querystring("SortBy")<BR> set rs=Server.CreateObject("adodb.Recordset")<BR> connectme="DSN=blank"<BR> sqlstmt = "SELECT * from inventory order by [&#060;%= SortBy %&#062;]"<BR> rs.open sqlstmt, connectme<BR>%&#062;<BR><BR>Then I have the links on the headers set up as such:<BR>&#060;A HREF="http://www.blank.com/inventory.asp?SortBy=Name%20of%20Field"&#062;Name of Field&#060;/A&#062;<BR><BR>What am I doing wrong?<BR><BR>Ray<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    1,671

    Default RE: Dynamic Sorting

    Try<BR><BR>sqlstmt = "SELECT * from inventory order by [" & SortBy & "]"<BR><BR>Since your script is entirely inside the &#060;% and %&#062; tags I don&#039t think you need the &#060;%= &#062; tag to get the value of SortBy<BR><BR>Mike

  3. #3
    Join Date
    Dec 1969
    Posts
    1,671

    Default RE: Dynamic Sorting

    try this:<BR><BR>&#060;%<BR>SortBy = request.querystring("SortBy")<BR>set rs=Server.CreateObject("adodb.Recordset")<BR> connectme="DSN=blank"<BR>sqlstmt = "SELECT * from inventory order by %&#062;&#060;%= SortBy %&#062;"<BR>rs.open sqlstmt, connectme<BR>%&#062;

Posting Permissions

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