Sorting with Strings

Results 1 to 6 of 6

Thread: Sorting with Strings

  1. #1
    Slowbob Guest

    Default Sorting with Strings

    I have a string, as shown below:<BR><BR>Dim SortType<BR>SortType = "BLAH"<BR><BR>I want to enter the string "SortType" into the following SQL Statement under "SortBy", as shown (wrongly?) below:<BR><BR>strSQL = "SELECT * FROM PlayerBank ORDER BY SortType"<BR><BR>Any help would be appreciated.<BR><BR>Slowbob

  2. #2
    Join Date
    Dec 1969

    Default You can't include a variable in a string...

    and expect it to work. You need to seperate it from the string:<BR><BR>"SELECT * FROM table WHERE sna=&#039fu&#039 ORDER BY " & sortType

  3. #3
    Slowbob Guest

    Default RE: You can't include a variable in a string..

    strSQL = "SELECT * FROM PlayerBank ORDER BY" & SortType<BR><BR>...Still not working...

  4. #4
    Slowbob Guest

    Default NM, got it working thanks


  5. #5
    Join Date
    Dec 1969

    Default Did you debug?

    If you&#039re having problems with SQL statements, you should always do a response.write after they&#039re created to see just exactly what they look like. I can show you exactly what yours will look like:<BR><BR>SELECT * FROM PlayerBank ORDER BYcolumnName<BR><BR>Are you seeing the error in there?

  6. #6
    JP Norair Guest

    Default RE: You can' include a variable in a string..

    Certain time when using embedded SQL you need to make sure to have a semicolon ";" You also need a space in there ater the BY.<BR><BR>strSQL = "SELECT * FROM PlayerBank ORDER BY " & SortType & ";"

Posting Permissions

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