php adodb连接带密码access数据库实例,测试成功
作者:
最近前台有个开票系统需要改进导致需要用PHP去连接那个系统的
数据库,ACCESS的带密码的。写了个简单的实例,记录下。
<?
include('./class/adodb/adodb.inc.php');
//实例化db类,链接
$db = ADONewConnection('ado_access');
$access = realpath('./rs.mdb');
$myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'.'DATA SOURCE='. $access . ';'."Jet OLEDB:Database Password=123456;";
$db->Connect($myDSN);
$recordSet = $db->Execute('select * from tt');
if (!$recordSet)
print $db->ErrorMsg();
else
while (!$recordSet->EOF) {
print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
$recordSet->MoveNext();
}
$recordSet->Close(); # 选择性执行
$db->Close(); # 选择性执行
?>
include('./class/adodb/adodb.inc.php');
//实例化db类,链接
$db = ADONewConnection('ado_access');
$access = realpath('./rs.mdb');
$myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'.'DATA SOURCE='. $access . ';'."Jet OLEDB:Database Password=123456;";
$db->Connect($myDSN);
$recordSet = $db->Execute('select * from tt');
if (!$recordSet)
print $db->ErrorMsg();
else
while (!$recordSet->EOF) {
print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
$recordSet->MoveNext();
}
$recordSet->Close(); # 选择性执行
$db->Close(); # 选择性执行
?>