我想通過php更新我的傳統訪問系統中的記錄,但在某些列上它不起作用。例如,下面的工作:PHP不允許某些列上的ACCESS更新
$query = "UPDATE Valuations SET SalesParticulars = '" . $salesparticulars . "',
Company = '" . $company . "' WHERE Ref=" . $ref;
如果我改變「公司」,以「名」這是行不通的,即使名稱只是在數據庫中的列完全一樣的公司。
基本上我可以更新「公司」,而不是「名」,儘管它們都是相同的數據類型
我得到這個例外,我怎麼能抓住它?
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Access Database Engine
Description: Syntax error in UPDATE statement.' in
這是我的全部代碼
// Create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
// Define the connection string and specify the database driver
$connStr = "PROVIDER=Microsoft.Ace.OLEDB.12.0;Data Source=".realpath("HS_BE.accdb").";";
// Open the connection to the database
$conn->open($connStr);
$name= "gareth";
// Declare the SQL statement that will query the database
$query = "UPDATE Valuations SET SalesParticulars = '" . $salesparticulars . "',
Name = '" . $name . "'
WHERE Ref=" . $ref;
echo $query;
// Execute the SQL statement and return records
$rs = $conn->execute($query);
你嘗試運行在MS Access直接相同的查詢?它工作嗎? – user4035
@ user4035是的,它的確很奇怪 –
有沒有辦法在執行查詢後得到錯誤? – user4035