SQLite Select…Where statement “no such column” error

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-25 00:39:23

问题


I have the following SQLite statement:

"SELECT * FROM HISTORICALPICKS WHERE BETTYPE = " + betType.ToString().ToUpper() + " ORDER BY DATETIME ASC"

And betType.ToString().ToUpper() is the string "ATS"

For some reason I get the following error:

System.Data.SQLite.SQLiteException : SQL logic error or missing database
no such column: ATS

...which leaves me baffled. ATS is not a column. BETTYPE is the column. I want it to select rows that have "ATS" in the BETTYPE column.

My hunch is that something is wrong with the syntax. Here is a picture showing the table name and column name, along with a highlight of the value ATS:


回答1:


You need single quotes around the value.

"SELECT * FROM HISTORICALPICKS WHERE BETTYPE = '" + betType.ToString().ToUpper() + "' ORDER BY DATETIME ASC"


来源:https://stackoverflow.com/questions/42868904/sqlite-select-where-statement-no-such-column-error

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