Android SQLite 问题,未找到列
我正在工作应用程序的民意调查部分,但我不断收到异常,说在将值插入数据库时找不到我的答案 2。
db.execSQL("UPDATE tblPoll SET Question='Who is more awesome?' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer1='Dan' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer2='Peet' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer3='Jordan' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer4='Spencer' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result1=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result2=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result3=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result4=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET resultTotal=0 WHERE rowid=1;");
这是我将项目插入行的代码,它适用于每个答案(团队成员),但皮特除外。我把皮特放在第一位、最后一位、第二位,而他是唯一打破这一规定的人。
private static final String DATABASE_CREATE =
"CREATE TABLE tblPoll (id INTEGER PRIMARY KEY, " +
"Question TEXT, Answer1 TEXT, Result1 NUMERIC, " +
"Answer2 TEXT, Result2 NUMERIC, Answer3 TEXT, " +
"Result3 NUMERIC, Answer4 TEXT, Result4 NUMERIC, " +
"ResultTotal NUMERIC);";
这是我用来制作表格的插入代码。
任何帮助将不胜感激。
@2red13 我像你一样运行了它(所有字段都正确填写,但在 Answer2 上仍然混乱。
新代码:
ContentValues werte = new ContentValues();
werte.put("Answer1", "Dan");
werte.put("Answer2", "Peet");
werte.put("Answer3", "Jordan");
werte.put("Answer4", "Spencer");
werte.put("Result1", 0);
werte.put("Result2", 0);
werte.put("Result3", 0);
werte.put("Result4", 0);
werte.put("ResultTotal", 0);
db.update("tblPoll", werte,"rowid=1",null);
I'm working a poll portion of an app for work and I keep getting an exception saying that my answer 2 is not found when inserting values into the database.
db.execSQL("UPDATE tblPoll SET Question='Who is more awesome?' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer1='Dan' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer2='Peet' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer3='Jordan' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET Answer4='Spencer' WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result1=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result2=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result3=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET result4=0 WHERE rowid=1;");
db.execSQL("UPDATE tblPoll SET resultTotal=0 WHERE rowid=1;");
This is my code to insert the items into the row, and it works for each of the answers(the members of the team), except for Peet. I've put Peet first, last, and as the second one, and he is the only one that breaks it.
private static final String DATABASE_CREATE =
"CREATE TABLE tblPoll (id INTEGER PRIMARY KEY, " +
"Question TEXT, Answer1 TEXT, Result1 NUMERIC, " +
"Answer2 TEXT, Result2 NUMERIC, Answer3 TEXT, " +
"Result3 NUMERIC, Answer4 TEXT, Result4 NUMERIC, " +
"ResultTotal NUMERIC);";
This is my insert code to make the table.
Any help will be greatly appreciated.
@2red13
I ran it like you had(with all the fields filled out properly, and it is still messing up on Answer2.
New code:
ContentValues werte = new ContentValues();
werte.put("Answer1", "Dan");
werte.put("Answer2", "Peet");
werte.put("Answer3", "Jordan");
werte.put("Answer4", "Spencer");
werte.put("Result1", 0);
werte.put("Result2", 0);
werte.put("Result3", 0);
werte.put("Result4", 0);
werte.put("ResultTotal", 0);
db.update("tblPoll", werte,"rowid=1",null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有任何 Peet schoud 失败的想法,但是你执行更新的方式有点慢,尝试:
也许它也解决了 Peet 问题 ^^
I havn't any Idea whi Peet schoud fail, but the way you perform the updates is alittle bit slow, try:
Maybe it solves the Peet Problem too ^^