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.

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

报告相同问题?

悬赏问题

  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启