[SQL ] 同樣使用update SQLite可以 但ACCESS不行

作者: kurapica1106   2020-10-21 01:41:08
資料庫名稱:SQLite3, Office 365 ACCESS
資料庫版本:
內容/問題描述:
我是非資工背景的初學者
在使用Excel VBA嘗試使用sql update
Dim Conn As Object
Dim SQL As String, Dbtype As String
Dbtype = "Access" '選擇使用Access或是SQLite
'Dbtype = "SQLite"
Set Conn = connectSQL(Dbtype)
SQL = "update book set price = 500 where id = 2"
Conn.Execute SQL
Conn.Close
Set Conn = Nothing
同樣的語法 update book set price = 500 where id = 2
在SQLite可以使用 但在ACCESS卻出現"準則運算式的資料類型不符合"
上網查了之後知道這是因為丟入的資料與資料庫內設定資料型態不合才出現的錯誤
但我不知道錯在哪裡
不知道板上的大大能不能幫小弟解惑
作者: LPH66 (-6.2598534e+18f)   2020-10-21 04:39:00
你去查你的 Access 資料庫是怎麼設定的特別是你有用到的欄位 `price` 和 `id`
作者: funk6478 (大恩)   2020-10-21 15:35:00
你ID設text 但你where id = 3是把它當數值

Links booklink

Contact Us: admin [ a t ] ucptt.com