用PHP到Access数据库文件的连接字符串是什么

|| 我安装了WAMP,我在项目文件夹中具有Access数据库文件,但是在我的计算机上没有安装Access。 即使没有安装Access,也可以使用PHP读取和更新Access文件吗? 以及与Access数据库文件的连接字符串是什么? 我真的需要帮助。     
已邀请:
        您只需要ODBC的PHP API。 这是来自文档本身的示例:
<?php
// Microsoft SQL Server using the SQL Native Client 10.0 ODBC Driver - allows connection to SQL 7, 2000, 2005 and 2008
$connection = odbc_connect(\"Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;\", $user, $password);

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

// Microsoft Excel
$excelFile = realpath(\'C:/ExcelData.xls\');
$excelDir = dirname($excelFile);
$connection = odbc_connect(\"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir\" , \'\', \'\');
?>
    
        // Microsoft Access 在控制面板中打开“管理工具”图标。 双击其中的数据源(ODBC)图标。 选择系统DSN选项卡。 单击系统DSN选项卡中的添加。 选择“ Microsoft Access驱动程序”。 单击完成。 在下一个屏幕中,单击“选择”以找到数据库。 为数据库指定数据源名称(DSN)。 单击确定。
$dsn=\'database.accdb\';
$username=\'\';
$password=\'\';
$connect=odbc_connect($dsn, $username, $password);
    
        我找到了有关此链接的教程。请注意,Windows和UNIX环境中的工作方式会有所不同,但是由于使用的是WAMP,因此应该没有问题。     
        
<?php

$db = $_SERVER[\"DOCUMENT_ROOT\"] .\"/AccessDatabase/reg.accdb\"; //AccessDatabase is folder in htdocs where the database is store 
if (!file_exists($db))
{
       die(\"No database file.\");
}

$dbNew = new PDO(\"odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$db; Uid=; Pwd=;\");
$sql = \"select * from reg\"; //reg is table name
$rs = $dbNew->query($sql);

while($result = $rs->fetch())
{
     echo $result[0].\": \".$result[1].\": \".$result[2].\"<br />\";
} 


?>
如果您遇到未安装pdo ODBC Drivers之类的错误 只需转到php.ini并找到extension = pdo_ODBC Driver并删除co​​mment(;) 之后,重新启动Apache     

要回复问题请先登录注册