SQL statement Order By

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesnkk
    New Member
    • Nov 2006
    • 134

    SQL statement Order By

    HI,
    I want to set the order by desc in the sql statement, but my statement cause
    BOF or EOF, what wrong with the statement ?
    Code:
    rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & " ORDER BY sn, debugno desc" & "'", conn
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Try it this way and see if it helps:
    Code:
    rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY debugno desc" , conn

    Comment

    • jamesnkk
      New Member
      • Nov 2006
      • 134

      #3
      Originally posted by puppydogbuddy
      Try it this way and see if it helps:
      Code:
      rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY debugno desc" , conn
      Error message display "Expected End of Statement"

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Originally posted by jamesnkk
        Error message display "Expected End of Statement"
        What part of the Sql statement was highlighted?

        Comment

        • puppydogbuddy
          Recognized Expert Top Contributor
          • May 2007
          • 1923

          #5
          Originally posted by puppydogbuddy
          What part of the Sql statement was highlighted?
          My mistake....I misread the sql...try it this way:
          Code:
          rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY sn, debugno, desc" , conn
          Last edited by puppydogbuddy; Jul 5 '08, 07:56 PM. Reason: typo

          Comment

          • jamesnkk
            New Member
            • Nov 2006
            • 134

            #6
            Originally posted by puppydogbuddy
            My mistake....I misread the sql...try it this way:
            Code:
            rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY sn, debugno, desc" , conn
            I think you miss out & and the " before ORDER, I manage to get it right,
            thank for the inspiration.
            Code:
            rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" & "ORDER BY SN,Debugno desc", conn

            Comment

            • puppydogbuddy
              Recognized Expert Top Contributor
              • May 2007
              • 1923

              #7
              Yes, you are correct. Sometimes, it is hard to see unless you have the database to in front of you to work with. Glad you got it resolved.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                Basically, it was a matter of moving the closing quote (') for the
                WHERE SN='blahBla ORDER BY ... '
                ...so that it comes before the ORDER BY instead of somtime afterwards. The later problems were due to missing and extra double-quotes (") - which can get confusing - especially if you're rushing.

                [ CODE ] tags always help to minimise these of course ;)

                Comment

                Working...