非常简单的sqlite查询“没有这样的列”

时间:2013-01-19 07:35:37

标签: android sqlite

这应该是一项非常简单的任务,但我已经被困了一个小时。

我在 sqlite浏览器中尝试了此查询,其工作

SELECT name FROM msUser WHERE username='admin' AND password='admin'

但是当我在Java代码中尝试这个时,它并没有意味着:

querySelect = "SELECT name FROM " + TABLE_NAME + " WHERE username = " + username + " AND password = " + password;

这就是日志猫所说的:

01-19 14:21:02.279: E/AndroidRuntime(3117): android.database.sqlite.SQLiteException: no such column: admin: , while compiling: SELECT name FROM msUser WHERE username = admin AND password = admin

请帮助我,谢谢:D

1 个答案:

答案 0 :(得分:2)

试试这个:

querySelect = "SELECT name FROM " + TABLE_NAME + " WHERE username = '" + username + "' AND password = '" + password +"'";