SQLite Exception no such column when trying to select

What’s happening here is that SQLite thinks that ‘pb3874’ is actually a column name, rather than a string/text literal.

To specify that it’s a text literal, you’ll want to ensure your text value is wrapped in the appropriate single quotes:

To prevent SQL injection attacks, whenever you’re taking input from the user, use a parameterized query:

("select count(*) from usertable where " + KEY_STUDID + "=?", studid);

Without parameterization (very much discouraged when taking user input):

("select count(*) from usertable where " + KEY_STUDID + "='" + studid + "'", null);  

The reason your numeric values didn’t produce this: SQLite converted those numeric literals for you.

Leave a Comment