doufan9377 2011-10-27 22:44
浏览 56
已采纳

使用PHP连接到MS Access DB

I need to access a MS Access database with PHP.

The MSAccess file's name can change so I am trying to use DSN'less connection string shown on PHP.net.

$mdbFilename='test.mdb';
$user = '';
$password = '';
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);

I am getting error;

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'., SQL state S1000 in SQLConnect in ...

I need some help connecting to that file.

(Extra question what to do if the file extension is not ".mdb" It's something like ".bws" )

Thanks

  • 写回答

1条回答 默认 最新

  • doujie1917 2011-10-27 23:11
    关注

    I believe you need the full path, not just the file name in the dbq parameter. everything else looks ok. .mdb is the standard extension for access database files. .bws is a disk image file. You may need to extract the file with something like Daemon Tools before you can use it.

    The syntax for a symlink in Windows Vista or 7 is

    MKLINK [[/D] | [/H] | [/J]] Link Target
    
        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.
    

    It won't work on a network share or from another OS, but a hard link (/H) will allow you to make a target for the ODBC driver that it can't distinguish from the real thing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元