Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Query work in Access Query, but don't work in C#

Query work in Access Query, but don't work in C#

Scheduled Pinned Locked Moved C#
helpdatabasecsharp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nta_3886
    wrote on last edited by
    #1

    My database Access have 3-columns : ID (int), Doc_no(string), Rcv_date(Date). I try to filter the newest row in the rows that have same Doc_no. i have a query for database Access :

    SELECT ID, Doc_No, Rcv_Date,
    FROM [SDC Documents Record] A
    WHERE (ID =
    (SELECT TOP 1 ID
    FROM [SDC Documents Record]
    WHERE (A.Doc_No = Doc_No)
    ORDER BY Rcv_Date DESC))

    That query still work well with Query Tool in Access, but in Query Builder in Visual Stuido 12 - C#, there are message : "Error in WHERE clause near 'ORDER'" . I don't know why. Plesea help me to fix it

    leo

    M B 2 Replies Last reply
    0
    • N nta_3886

      My database Access have 3-columns : ID (int), Doc_no(string), Rcv_date(Date). I try to filter the newest row in the rows that have same Doc_no. i have a query for database Access :

      SELECT ID, Doc_No, Rcv_Date,
      FROM [SDC Documents Record] A
      WHERE (ID =
      (SELECT TOP 1 ID
      FROM [SDC Documents Record]
      WHERE (A.Doc_No = Doc_No)
      ORDER BY Rcv_Date DESC))

      That query still work well with Query Tool in Access, but in Query Builder in Visual Stuido 12 - C#, there are message : "Error in WHERE clause near 'ORDER'" . I don't know why. Plesea help me to fix it

      leo

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      The ( puts the ORDER BY inside your WHERE clause, you have 2x ( and 3x )

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • N nta_3886

        My database Access have 3-columns : ID (int), Doc_no(string), Rcv_date(Date). I try to filter the newest row in the rows that have same Doc_no. i have a query for database Access :

        SELECT ID, Doc_No, Rcv_Date,
        FROM [SDC Documents Record] A
        WHERE (ID =
        (SELECT TOP 1 ID
        FROM [SDC Documents Record]
        WHERE (A.Doc_No = Doc_No)
        ORDER BY Rcv_Date DESC))

        That query still work well with Query Tool in Access, but in Query Builder in Visual Stuido 12 - C#, there are message : "Error in WHERE clause near 'ORDER'" . I don't know why. Plesea help me to fix it

        leo

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        SELECT ID, Doc_No, Rcv_Date, FROM

        the last comma is wrong - but with it, the query should not run in MS Access either.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups