<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8″>
</head>
<body>
<?php
//print("The next line generates an error.www.jb51.net<br>");
//printaline("PLEASE?");
//print("This will not be displayed due to the above error.");
?>
<?php
$conn = new COM("ADODB.Connection", NULL, CP_UTF8) or die("Cannot start ADO");
//access
数据库的打开方式
//$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
//$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");
$conn->Open("Driver={SQL Server};Server={192.168.22.40};Database=sugarcrm_db;UID=sa;PWD=123456;") ;
// 执行查询并输出数据 www.plcxue.com
$rs = $conn->Execute('SELECT * FROM accounts') or die ("error query");
?>
<table border="1″>
<tr><th>ID</th><th>Title</th>
</tr>
<?php
while (!$rs->EOF) {
echo '<tr>';
echo '<td>'. $rs->Fields['id']->Value .'</td>';
echo '<td>'. $rs->Fields['name']->Value .'</td>';
echo '</tr>';
$rs->MoveNext();
}
?>
</table>
<?php
// 释放资源
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
</body>
</html>