dpzbzp8728 2015-07-10 13:14
浏览 88

无法使用PHP读取MS Access表(链接到ODBC数据源)

I am working on an application in which the data from an ODBC enabled Data Source is imported to an MS Access 2007 Database using a Linked Table. The tricky part is that every time a Link Refresh is made (or the linked table is opened) the ODBC Data Source prompts out a Window where 4 different parameters (username, password, servername, workgroupname) have to be input.

While this is possible manually, I find no way to read this linked Table programatically.

I am using a PHP Script to read the linked table. The Execution of PHP Script is halted indefinitely when I try to read this linked table. My DSN is properly configured and can successfully read the data in all other cases including those linked tables in which the data source doesnot require any input parameters/credentials. However, it fails in this case.

In a nutshell, my system is PHP<-->MS Access (Linked Table)<--ODBC Data Source. The PHP Script aims to read the updated data from the ODBC Data Source using the Linked Table. For some reasons, PHP cannot directly interface with the ODBC Data Source, so I am using MS Access as an intermediary.

The odbc_connect function of PHP allows only DSN Name, username, password, cursor_type as parameters. I am not sure how do I input the 4 parameters (username, password, servername, workgroupname) as required by the ODBC Data Source to which my MS Access table is linked.

I am using PHP 5.4 on Windows 7 with MS Access 2007.

I request the developer community to help me with necessary pointers on this. Any suggestions for Workaround is also welcome.

Thanks in Advance.

  • 写回答

2条回答 默认 最新

  • dongtang9855 2015-07-10 15:44
    关注

    if you are using double ODBC: PHP > ODBC > MS ACCESS > ODBC > SOURCE.. you have following options.

    • Cut off the "Access" middle man and connect directly.
    • if you want to use MS Access, use "FILE DNS" to connect to the linked tables from MS ACCESS where file DNS has all 4 parameters initialized. (This will eliminate MS Access asking you to enter the server information when refreshing linked tables)
    • Haven't tried this from PHP side but you can loop through the msysobjects table or database.tabledefinitions and update the link with your custom connection string.

    Any way, the solution for your trouble would be. Make Access not to prompt for parameters when refreshing linked tables by either using file dns or save passwords.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度