No such column SQLite

烈酒焚心 提交于 2021-01-29 07:06:11

问题


Okay i tried everyting i could, i saw all the posts here about this error and none of them solved my problem:

Here is my simple update statement, i would like to increment each itemSlotIndex by 1 at a certain characterName

String myQuery = "UPDATE " + theTable.getTableName() + " SET " + theTable.getItemSlotIndex()

        + " = " + theTable.getItemSlotIndex() + " + 1 WHERE " + theTable.getCharName() + " = "+character.getName();

        Log.i("myQuery", myQuery);

        theDatabase.execSQL(myQuery);

If this mumbo jumbo could be misleading, here is my logcat output for the SQL statement:

UPDATE CharsTable SET slot_index = slot_index + 1 WHERE char_name = Francis

As you see,

CharsTable is my table

slot_index is the attribute, i would like to increment

and the where claus is: I only want to update rows with char_name equals "Francis"

And the error is just wow:

02-06 19:01:13.472: E/SQLiteLog(16743): (1) no such column: Francis

No such column!!!

I got no such column error for adding a where clause parameter.

Any ideas what m i doing wrong ?


回答1:


You have forgot the '' around Francis :

UPDATE CharsTable SET slot_index = slot_index + 1 WHERE char_name = 'Francis'

... + " = '"+character.getName() + "'";



回答2:


Quotes around your string value?



来源:https://stackoverflow.com/questions/21610600/no-such-column-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!