//mssql.php
$host="localhost";
$user="sa";
$password="";
$db="kao";error_reporting(7);
if(!$sql) $sql="select @@VERSION";
echo "
";
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=SQLOLEDB; Data Source=$host;
Initial Catalog=$db; User ID=$user; Password=$password");$rs = $conn->Execute($sql);
$num_columns = $rs->Fields->Count();
echo $num_columns . "\n";
for ($i=0; $i {
$fld[$i] = $rs->Fields($i);
}$rowcount = 0;
while (!$rs->EOF)
{
for ($i=0; $i {
echo $fld[$i]->value . "\t";
}
echo "\n";
$rowcount++;
$rs->MoveNext();
}$rs->Close();
$conn->Close();$rs->Release();
$conn->Release();$rs = null;
$conn = null;
?>
php与Access数据库连接的代码
$dbc=new com("adodb.connection");
$dbc.open("driver=microsoft access driver (*.mdb);dbq=c:\member.mdb");
$rs=$dbc->execute("select * from tablename");
$i=0;
while (!$rs->eof){
$i+=1
$fld0=$rs->field(0);
$fld1=$rs->field(1);
....
echo "$fld0->value $fld1->value ....";
$rs->movenext();
}
$rs->close();
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn