iT邦幫忙

0

android studio Sqlite update無法Where到Text類型

  • 分享至 

  • twitterImage

android studio Sqlite update無法Where到Text類型

ContentValues contentValues = new ContentValues(); contentValues.put("passwd",tnewpassword); db.update(DataBaseTable,contentValues,"name= a123" ,null);

name 的型態是"name text PRIMARY KEY not null,"
這是我的Sqlite 的程式碼
範例的update code

count=db.update(DataBaseTable,contentValues,"_id="+AccountArray[spinner.getSelectedItemPosition()],null);

那在這邊他的_id 是_id INTEGER PRIMARY KEY AUTOINCREMENT,"

我有改範例的where改成text也變成無法更新

跳出的錯誤如下!
https://ithelp.ithome.com.tw/upload/images/20210625/201266488fwDdvdKjw.png

但以上問題 只要所創的name是全數字 就正常

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
小魚
iT邦大師 1 級 ‧ 2021-06-25 00:27:36
最佳解答

"name= a123" 是不是要改成 "name= 'a123'"?

另外name為什麼會變成id?
id聽起來就是數字...吧?

看更多先前的回應...收起先前的回應...
aith3r iT邦新手 5 級 ‧ 2021-06-25 00:52:31 檢舉

你好~.
那個id是範例的拉XD

aith3r iT邦新手 5 級 ‧ 2021-06-25 00:55:57 檢舉

有了 抱歉哥
第一次寫沒經驗QQ 感謝!!

小魚 iT邦大師 1 級 ‧ 2021-06-25 01:12:47 檢舉

因為它是字串,
但是這樣寫會不會有SQL Injection的問題,
如果where條件是使用者輸入的話.

aith3r iT邦新手 5 級 ‧ 2021-06-25 01:21:19 檢舉

感謝您/images/emoticon/emoticon07.gif受教了

我要發表回答

立即登入回答