推 LPH66: 你去查你的 Access 資料庫是怎麼設定的 10/21 04:39
→ LPH66: 特別是你有用到的欄位 `price` 和 `id` 10/21 04:39
Dim Conn As Object
Dim SQL As String, Dbtype As String
Dbtype = "Access"
'Dbtype = "SQLite"
Set Conn = connectSQL(Dbtype)
SQL = "Create table book (ID text, Name text, Page int, Price int)"
Conn.Execute SQL
Conn.Close
Set Conn = Nothing
上面是一開始設定資料庫的程式
Dim Conn As Object
Dim SQL As String, Dbtype As String
Dbtype = "Access"
Set Conn = connectSQL(Dbtype)
SQL = "insert into book (ID, Name, Page, Price) values (1, 'Word 2013',
356, 450)"
Conn.Execute SQL
SQL = "insert into book (ID, Name, Page, Price) values (2, 'Python', 123,
420)"
Conn.Execute SQL
SQL = "insert into book (ID, Name, Page, Price) values (3, 'C++', 545,
360)"
Conn.Execute SQL
Conn.Close
Set Conn = Nothing
這段是輸入三筆資料
到了後面我發現我除了使用update有"準則運算式的資料類型不符合"的問題外
使用delete from book where id = 3也會出現相同的錯誤訊息
不知道ACCESS的那個ID欄位設定出了什麼問題
晚點回公司再查查
感謝大大
→ funk6478: 你ID設text 但你where id = 3是把它當數值 10/21 15:35
哇 真的
太感謝你了
※ 編輯: kurapica1106 (223.136.37.221 臺灣), 10/21/2020 17:18:37