SQLiteException: no such column:好

    今天在使用Android SQLite数据库时碰到下面的错误:

    Caused by: android.database.sqlite.SQLiteException: no such column: 好

    代码如下:

Cursor cr = db.query(DBHelper.TABLE_LOCKS, columns, "lname=" + name, null,
				null, null, null);


    在网上查阅了很多资料后,发现是由于查询的lname列元素为String类型,而查询语句中的String要用单引号引起来,代码修改后正确,正确形式如下:

Cursor cr = db.query(DBHelper.TABLE_LOCKS, columns, "lname='" + name +"'", null,
				null, null, null);

你可能感兴趣的:(android,SQLiteException,noSuchColumn)