Results 1 to 5 of 5

Thread: Syntax Error?

  1. #1
    Join Date
    Nov 2003
    Location
    Fort Stockton, Texas
    Posts
    3

    Question Unanswered: Syntax Error?

    Using this Query:
    SELECT * FROM Thomas1 ORDER BY RecordId DESC LIMIT 1;

    I Get this Error:
    MySQL][ODBC 3.51 Driver][mysqld-3.23.58-nt]You have an error in your SQL syntax near 'SELECT * FROM Thomas1 ORDER BY RecordId DESC LIMIT 1' at line 1

    Can you see the error?
    This query works from Navicat
    But not when I Use it in ASP.

  2. #2
    Join Date
    Nov 2003
    Posts
    91
    This is my guess:

    'LIMIT 1' is not standard SQL (it is a MySQL extension)
    and ODBC might be choking on this.
    Some ODBC drivers have 'passthrough' capabilities
    that don't try to parse the SQL statement, and thus
    would allow this non-standard SQL statement to pass
    through directly to the MySQL server.
    I don't know whether the MySQL ODBC drivers have
    this capability or not since I don't use it, but if you
    want to test this theory just delete the 'LIMIT 1' from
    your query.

    -lv

  3. #3
    Join Date
    Nov 2003
    Location
    Fort Stockton, Texas
    Posts
    3

    Update info

    Thanks for responding.
    I tried what you said and here's what I got:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [MySQL][ODBC 3.51 Driver][mysqld-3.23.58-nt]You have an error in your SQL syntax near 'SELECT * FROM Thomas1 ORDER BY RecordId DESC' at line 1

    and check this out:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [MySQL][ODBC 3.51 Driver][mysqld-3.23.58-nt]You have an error in your SQL syntax near 'SELECT * FROM Thomas1' at line 1

    How is this? (The apostrophies are not sent in by me.)
    I'm lost.

  4. #4
    Join Date
    Nov 2003
    Posts
    91
    There is nothing wrong with your syntax
    (SELECT * FROM Thomas1).
    The syntax error message is a red herring. Ignore it -- you
    probably have something more seriously wrong.

    I'm thinking you have an incompatibility btn the
    versions of software you are using, or something's
    not installed right. Version 3.51 is supposed to be stable,
    as well as MySQL 3.23.58, so those pgms are probably OK.

    You may want to create a trace log to see
    where the ODBC driver is failing. There is a MySQL
    ODBC faq that explains this at:
    http://www.mysql.com/products/myodbc/faq_1.html#SEC12

    Go back to 'ODBC Data Source Administer' and make sure
    the driver and data source is listed in either the 'User DSN'
    tab or the 'System DSN' tab.

    One other thing you can try: sometimes SQL
    statements require a semicolon on the end, and
    sometimes not. Try it both ways and see what happens.
    In other words, try
    SELECT * FROM Thomas1;

    Sorry I can't be of any more help.

    -lv

  5. #5
    Join Date
    Nov 2003
    Location
    Fort Stockton, Texas
    Posts
    3

    Smile Thanks again

    I have contacted my server admin.
    One other thing I forgot to mention.
    ADO cannot resolve the recordcount of returned recordsets.
    I open a recordset that contains 22 records, I can iterrate through them, but recordcount always equates to -1.
    I'm sure this is related as I have never had this problem either.
    Thank you for your help.
    I'm sure your post will help them identify the problem.

Posting Permissions

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