Sqlite 插入数据数据时提示没有该列:
android.database.sqlite.SQLiteException: table splitTable has no column named isLast (code 1):
此时可以查看该表的创建结构,然后调整列名称,重新调用插入的方法。
Cursor cursor = db.rawQuery("select * from sqlite_master where type= 'table' and name='" + tableName + "'", null);
/**
* 查询到结果对应的列名与位置
* 0 = "type"
* 1 = "name"
* 2 = "tbl_name"
* 3 = "rootpage"
* 4 = "sql"
**/
if (cursor.moveToNext()){
String sql = cursor.getString(cursor.getColumnIndex("sql"));
Log.d(TAG, "showCreateTable: sql " + sql);
}
本文详细解析了在使用Sqlite进行数据插入时遇到“没有该列”错误的原因及解决方案,通过检查表结构并调整列名称,成功解决了数据插入失败的问题。

被折叠的 条评论
为什么被折叠?



