Home > php教程 > php手册 > body text

PHP使用PDO连接Access的方法

WBOY
Release: 2016-06-13 11:33:47
Original
1558 people have browsed it

  try{

  $db = new PDO("odbc:driver={microsoft access driver (*.mdb)};dbq=".getcwd()."#db.mdb");

  echo "Connectedn";

  } catch (Exception $e) {

  echo "Failed:".$e->getMessage();

  }

  连接成功!如果没有,请确认PDO扩展已安装,打开php.ini,查看有没有这么一句:extension=php_pdo_odbc.dll

  没有的话自行添加,可以调用phpinfo()查看扩展有没有正确的安装!

  如果有图中红色框内的就是正确安装了。

  这里有个小小的注意,字符串“(*.mdb)”的前面必须有一个空格,

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template