问题
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