table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

在Android Studio中练习SQLite数据库时报错

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

E/SQLiteLog: (1) table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)”
E/SQLiteDatabase: Error inserting age=20 name=张三
android.database.sqlite.SQLiteException: table student has no column named age (code 1 SQLITE_ERROR): , while compiling: INSERT INTO student(age,name) VALUES (?,?)

显示原因是:表学生在”插入学生(年龄,姓名)值 (?,?) 中没有名为年龄的列(标黄字段翻译)

是因为创建的时候少了空格

错误程序:

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

正确程序:

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

差别在 + 前有无空格

但改好之后仍然报错,是因为数据库已经创建好了,数据库里面已经存储了未添加空格之前的记录

所以,我们改个数据库名就好了

前数据库名:wzxDB 后数据库名:wzx.DB

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

运行成功:

table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

Original: https://blog.csdn.net/m0_53688926/article/details/127847187
Author: wzx1005
Title: table student has no column named age in “INSERT INTO student(age,name) VALUES (?,?)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/815737/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球