Results 1 to 3 of 3

Thread: help with ADO Sql statement

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    230

    Question help with ADO Sql statement

    What is wrong with this code? It tells me missing operator error.
    I want my results to be ordered by ProductCode and be between StartPlu and EndPlu...

    rsOrderDetails.Open "SELECT * From OrderDetails ORDER BY ProductCode WHERE ProductCode >= " & StartPlu & " and ProductCode <= " & EndPlu & "", CN, , adLockOptimistic

  2. #2
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245

    Re: help with ADO Sql statement

    Originally posted by TSur
    What is wrong with this code? It tells me missing operator error.
    I want my results to be ordered by ProductCode and be between StartPlu and EndPlu...

    rsOrderDetails.Open "SELECT * From OrderDetails ORDER BY ProductCode WHERE ProductCode >= " & StartPlu & " and ProductCode <= " & EndPlu & "", CN, , adLockOptimistic
    Order By is ALWAYS the last thing in an SQL statement. Put the WHERE clause before it.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this:

    VB Code:
    1. rsOrderDetails.Open "SELECT * From OrderDetails WHERE ProductCode >= " & _
    2.    StartPlu & " and ProductCode <= " & EndPlu & " ORDER BY ProductCode", _
    3.    CN, , adLockOptimistic
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

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



Click Here to Expand Forum to Full Width