www.webdeveloper.com
Results 1 to 4 of 4

Thread: Sort in ASP (error)

  1. #1
    Join Date
    Jun 2006
    Location
    Yorkshire, England
    Posts
    109

    Sort in ASP (error)

    Hi,
    What am I doing wrong here,as my sort is not working?

    mySort = Request("sort")

    IF myGen = "staff" THEN
    mySQLb = "SELECT * From tblstaff WHERE Age >='" & myMin & "' AND Age <='" & myMax & "'"

    mySQLb = mySQLb & "ORDER BY Age'" & mySort & "'"

    Any Clues?

  2. #2
    Join Date
    Feb 2003
    Posts
    2,745
    you need a space b4 ORDER
    Code:
    mySQLb = mySQLb & " ORDER BY Age, " & mySort
    also, always do a Response.Write sql

    to see what you are sending to the database when u get an error.

    edit also, you have some extra quotes and are missing a comma

  3. #3
    Join Date
    Jun 2006
    Location
    Yorkshire, England
    Posts
    109

    Unhappy

    Thanks for the response.

    I still get this:
    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in ORDER BY clause.

    ALSO:
    POST Data:
    type=staff&minAge=00&maxAge=56&sort=asc&Submit=Perform+Search

    mySQLb = mySQLb & " ORDER BY Age, " & mySort

  4. #4
    Join Date
    Feb 2003
    Posts
    2,745
    ok. remove the comma. i thought u were sorting by 2 fields, didnt know u were appending asc or desc.

    also, remeber to response.write sql so you can see the query. this would make the problem obvious.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles