PHP如何连接Access数据库


PHP代码:
  1. <?php
  2. $connstr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data.mdb");
  3. $connid=odbc_connect($connstr,"","",SQL_CUR_USE_ODBC);
  4. $issuetime=date("Y-m-d H:i:s");
  5. $sql="insert into test values("","",...)";
  6. $result=odbc_exec($connid,$sql);
  7. if($result) echo "successful";
  8. else echo "failed";
  9. ?>

之二:

  1. <?PHP
  2. //创建ADO连接
  3. $conn = @new COM("ADODB.Connection") or die ("ADO连接失败!");
  4. $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("temp/TempData.mdb");
  5. $conn->Open($connstr);
  6.  
  7. //创建记录集查询
  8. $rs = @new COM("ADODB.RecordSet");
  9. $rs->Open("select * from blog_Content",$conn,1,3);
  10. echo $rs->Fields["log_Title"]->Value;    //输出log_Title字段
  11. echo "<br/>";
  12. $rs->Movenext();    //将记录集指针下移
  13. echo $rs->Fields["log_Title"]->Value;
  14. $rs->close();
  15. ?>


相关阅读:
mysql Incorrect file format 表修复
phpStudy + phpfind + phpLight 最新PHP集成包全在这里
phpmyadmin出现“Cannot start session without errors”
php环境搭建利器phpStudy实战各种php程序
phpfind 2013.3.15 最新版下载
phpLight 2013.3.15下载
phpStudy 2013.3.23 phpStudy最新版,重写版下载
APACHE支持.htaccess以及 No input file specified解决方案
phpStudy + phpfind + phpLight 使用说明
phpLight 2013 Build 0210 phpLight下载
phpfind 2013 php 5.3.21下载 phpfind 2013 Build 0205
phpstudy dedecms后台/dede/login.php登录空白解决办法
快速导航

Copyright © 2016 phpStudy |