ODBC Errors In Query

From: Steve (racquetballer_at_hotmail.com)
Date: 10/23/04

  • Next message: Pjotr Wedersteers: "Re: clearing out all $_SESSOIN variables?"
    Date: Sat, 23 Oct 2004 05:21:59 GMT
    
    

    I normally use MySQL with PHP, but I'm delving into connecting to Access
    with ODBC (for a database that I already have set up at work), and I'm
    running into a couple of errors. I'm just trying to do a simple query
    with two columns - one a name (VARCHAR), and one an integer column.

    First, if I add an ORDER BY clause, so the query looks like this:

    $sql = "select tblScores.FullName, sum(tblScores.Points) as TotalPoints
    from tblScores WHERE Division='MO'";
    $sql = $sql." GROUP BY tblScores.FullName";
    $sql= $sql." ORDER BY TotalPoints desc";

    I get an ODBC error that says:

    "odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too
    few parameters. Expected 1., SQL state 07001 in SQLExecDirect in
    c:\program files\apache group\apache\htdocs\odbc\file.php on line 15"

    However, if I remove the ORDER BY clause, the query runs (although the
    data isn't sorted the way I would like). I have a feeling it might be
    something in my SQL, but I can't see it.

    Later, I did discover that if I use

    ORDER BY sum(tblScores.Points)

    instead of the alias (TotalPoints) the query works fine. That seems odd
    to me, because everything I've read is that you should be able to use an
    alias in an ORDER BY clause. Why would it behave that way when
    connecting via ODBC and not for MySQL?

    The second thing I'm noticing is that even though I'm using an integer
    field, there is a decimal on the end of each number (i.e. 25.0 instead
    of 25). When I run the same query using MySQL, there is no decimal
    point, which is as it should be.

    Can anyone explain why I am getting these errors?

    Thanks.

    Steve


  • Next message: Pjotr Wedersteers: "Re: clearing out all $_SESSOIN variables?"

    Relevant Pages

    • Re: Official Status of SQLServer 2005 ADP
      ... I have said that the support for SQL passthrough ... queries under MDB was bad and worst than the one offered by ADP while you ... > attempt to "pass through" every Access query against a linked ODBC ...
      (microsoft.public.access.adp.sqlserver)
    • Re: Excel: terrible performance
      ... You should also check that you don't have logging enabled on the ODBC ... If you execute the SQL in Query analyser you may be able to improve the ... spreadsheet comes to about ...
      (microsoft.public.sqlserver.odbc)
    • Re: Stop to modify the SQL query manually entered into query !
      ... Edit button so you just dump the SQL in and be done with it. ... You can go the ODBC route, or the ADO route. ... >>> with Oracle, when using functions in a manual SQL query into Excel, the>> alias for the ciolumns are SYTEMATICALLY ignored or dropped. ...
      (microsoft.public.excel.programming)
    • Re: SQL using C
      ... I am almost a new C programmer and now I need to use SQL within my C ... The people who are telling you to use a C API are out of their mind. ... MySQL + PHP), then the MySQL C API is a rather good option to get ... Because ODBC is extremely well documented. ...
      (comp.lang.c)
    • Re: PASS THROUGH QUERY WITH ORACLE BACK END
      ... Could you post the SQL for your query? ... Which ODBC driver are you using? ... > error retrieving data but I always get the odbc call failed error message. ...
      (microsoft.public.access.queries)

    Loading