我有一個MS Access數據庫。我想獲取記錄,然後寫入二維數組。我可以但我認爲記錄集內存區和陣列內存區相同。因爲如果我關閉記錄集,我無法訪問數組值。MS Access ADO記錄集和二維數組
Error: Catchable fatal error: Object of class variant could not be converted to string in ...
$databaselocation = $_SERVER['DOCUMENT_ROOT'] . "ornek.mdb";
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
$conn->Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=$databaselocation");
$SQL1 = "SELECT * from konu";
$rs = new com("ADODB.RecordSet") or die("Recordset cant create!");
$rs->Open($SQL1,$conn,1,3);
$say = $rs->RecordCount();
echo "Row Counts: " . $say . "<br><br>";
$dizi = array(array());
for($a=0; $a<$say; $a++)
{
$dizi[$a][0] = $rs[0];
$dizi[$a][1] = $rs[1];
$rs->MoveNext;
}
$rs->Close(); $conn->Close();
$rs = null; $conn = null;
echo $dizi[0][0]; // this line ERROR same below
for($a=0; $a<$say; $a++)
{
echo $dizi[$a][0] . " - " . $dizi[$a][1] . "<br>"; // ERROR
}
你可以顯示/打印$ dizi數據。的print_r($笛子); –
確實,'$ dizi'是否爲空?運行'var_dump($ dizi)'。好奇,你有沒有[PDO-ODBC](http://php.net/manual/en/ref.pdo-odbc.php)連接到MS Access與PHP API而不是COM接口? – Parfait