热门资源

我把刚才的ACCESS库在DSN中取名test

具体的解决方法如下:下载ADO的ZIP包,该东东用PHP实现ADO同各种各样数据库打交道。解包,里面文件很多,不过有用的只有ohtml.inc.php和adodb.inc.php,把它们复制到相应目录下;然后在本鸡的c:myphp目录下(iis下设置通过来访问),造了一个名为test.mdb的access库,里头再造个experts的表。为了通过DSN来访问,我把刚才的ACCESS库在DSN中取名test。运行。看着说明书我造了这么个程序:dbtest.php,内容如下:?phpinclude(‘tohtml.inc.php’);
// load code common to ADODBinclude(‘adodb.inc.php’); // load code
common to ADODB$conn = ADONewConnection(‘access’); // create a
connection$conn-PConnect(‘test’);// connect to MySQL, agora db$sql =
‘select name, group1 from experts’;$rs =
$conn-Execute($sql);rs2html($rs,’border=2 cellpadding=3′,array(‘Customer
Name’,’Customer ID’));$rs-Close(); // optional$conn-Close(); //
optional?然后,IE中打入:唉!结果出来了。 令人基本满足!!
接着,我又想:还要设置DSN,烦不烦!绕过DSN应如何解决?因为在asp中,我习惯用conn.open(provider=Microsoft.Jet.OLEDB.4.0;Data
Source=
Server.Mappath(../nydatabase.mdb))来处理mdb库,那速度快呀!?想了又想,看了又看。找找找,,嘿嘿,终于在testdatabases.inc.php
中找到了答案! 我再把刚才的程序改编:?phpinclude(‘tohtml.inc.php’); //
load code common to ADODBinclude(‘adodb.inc.php’); // load code common
to ADODB$db = ADONewConnection(ado_access);print h1Connecting
$db-databaseType…/h1;$access = ‘test.mdb’;$myDSN =
‘PROVIDER=Microsoft.Jet.OLEDB.4.0;’.’DATA SOURCE=’. $access . ‘;’;.’USER
ID=;PASSWORD=;’;if (@$db-PConnect($myDSN, , , )) {print ADO
version=.$db-_connectionID-version.br;$sql = ‘select name, group1 from
experts’;$rs = $db-Execute($sql);rs2html($rs,’border=2
cellpadding=3′,array(‘Customer Name’,’Customer ID’));} else print ERROR:
Access test requires a Access database $access.’BR’.$db-ErrorMsg();?

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章