Ms Access connect how to?

Hi im trying to connect to a msaccess db using a previous example to load a grid.
I dont know what i’m doing wrong. Would you help me?

Here’s the connector and the log file.
The php.ini is attached.

Thanks in advance

Warm regards from Argentina

Lux

<?php require("dhtmlxConnector/codebase/grid_connector.php"); require("dhtmlxConnector/codebase/db_pdo.php"); $res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Archivos.mdb;Uid=Admin"); $grid = new GridConnector($res,"PDO"); $grid->enable_log("log"); $name = intval($_GET['id']); $grid->dynamic_loading(100); $grid->render_sql("SELECT factven.VenFecVto, factven.VenNum, factven.VenNom, factven.VenTotal FROM agente Inner Join factven ON factven.VenAgeNum = agente.AgeNum WHERE agente.AgeTel ='" .$id. "'and MONTH(factven.VenFecVto)=MONTH(CURRENT_DATE) and YEAR(factven.VenFecVto)=YEAR(CURRENT_DATE) ","factven.VenNum","factven.VenFecVto,factven.VenNom,factven.VenNum,factven.VenTotal"); ?>


Log started, 14/05/2011 05:05:20

SELECT
factven.VenFecVto,
factven.VenNum,
factven.VenNom,
factven.VenTotal
FROM agente
Inner Join factven ON factven.VenAgeNum = agente.AgeNum WHERE
agente.AgeTel ='SIP/200’and MONTH(factven.VenFecVto)=MONTH(CURRENT_DATE) and YEAR(factven.VenFecVto)=YEAR(CURRENT_DATE)
LIMIT 0,100

!!!Uncaught Exception
Code: 0
Message: PDO - sql execution failed
Array
php.rar (14.2 KB)

Try to comment “$grid->dynamic_loading(100);” line.
MS Access doesn’t support “limit” command, so dyn. loading will not work for it.

Thank you for your quick response,
I comment “$grid->dynamic_loading(100);” line.
and still getting the following log.

SELECT
factven.VenFecVto,
factven.VenNum,
factven.VenNom,
factven.VenTotal
FROM agente
Inner Join factven ON factven.VenAgeNum = agente.AgeNum WHERE
MONTH(factven.VenFecVto)=MONTH(CURRENT_DATE) and YEAR(factven.VenFecVto)=YEAR(CURRENT_DATE)

!!!Uncaught Exception
Code: 0
Message: PDO - sql execution failed

Is there a working sample so i can figure it out?
Thanks in advance

Lux
Array

May be caused by some aspects of DB structure
Can you try to run the same query, as was written in the log, directly against Access DB, it may show some more detailed error message.

For plain tables, Access connection definitely works (was tested locally)

Stanislav. Im still stuck with these.
I reformulated the query to test it.
The server side code is:

Documento sin título <?php require("dhtmlxConnector/codebase2/grid_connector.php"); require("dhtmlxConnector/codebase2/db_pdo.php"); $res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Archivos.mdb"); $grid = new GridConnector($res,"PDO"); $grid->enable_log("log"); $grid->render_sql("SELECT CLIENTES.CliNum FROM CLIENTES","CLIENTES.CliNum","CLIENTES.CliNum"); ?>

And im recibing this log.

Log started, 17/05/2011 06:05:49

SELECT CLIENTES.CliNum FROM CLIENTES

Cannot modify header information - headers already sent by (output started at C:\AppServ\www\dhtmlx\access.php:6) at C:\AppServ\www\dhtmlx\dhtmlxConnector\codebase2\base_connector.php line 37

Done in 0.321086883545s

As can you see, there’s no blank spaces in the server side code.

Can you tell me what’s happening?
P.D.: Server side code is attached.
Thanks in advance.

Lux
access.rar (512 Bytes)

Remove all non-php content from the file - currently it has head section, which is not necessary and causes problem during output generation.

Updated php file is attached.
access_updated.zip (344 Bytes)

Thanks Stanislav, the thing is now i can connect to db but im receiving this strange xml output:

<?xml version="1.0" encoding="utf-8" ?>

An the log output is

Log started, 19/05/2011 07:05:35

SELECT AGENTE.AgeNum,AGENTE.AgeNom FROM AGENTE

Undefined index: AGENTE.AgeNom at C:\AppServ\www\dhtmlx\dhtmlxConnector\codebase2\grid_connector.php line 111

Undefined index: AGENTE.AgeNom at C:\AppServ\www\dhtmlx\dhtmlxConnector\codebase2\grid_connector.php line 111

Undefined index: AGENTE.AgeNom at C:\AppServ\www\dhtmlx\dhtmlxConnector\codebase2\grid_connector.php line 111

in other application im using i got the same response. So i had to degrade to connector 0.96 instead of 1.0 and i got it working. But 0.96 hasnt got the pdo connector.
What can i do?

In your old code, you had the next line

$grid->render_sql(“SELECT CLIENTES.CliNum FROM CLIENTES”,“CLIENTES.CliNum”,“CLIENTES.CliNum”);

Try to change it as

$grid->render_sql(“SELECT CLIENTES.CliNum as CliNum FROM CLIENTES”,“CLIENTES.CliNum(CliNum)”);

Same for other fields, which are included in the sql code with table prefix.

Thank Stanislav. Now it working.

Now im trying to filter grid, i tryed using dhxGrid.attachHeader("#connector_text_filter), but is not working. There’s no native approach as in mysql. How could filter from client side?

You need to

  • add in the header #connector_text_filter
  • include connector.js on the page

It will render filter box and will reload data from server side when you are entering text in the filter box.

Now, if it doesn’t reloads correct - try to check server side logs, they will show the exact filtering query as it was generated. If it doesn’t suit your needs - it possible to redefine how filter values injected in sql query through beforeFilter server side event.