gpt4 book ai didi

java - SQLite异常: no such table: trainingsplan (code 1) while compiling: select statment

转载 作者:行者123 更新时间:2023-12-01 13:16:08 36 4
gpt4 key购买 nike

这是我的数据库代码

    private SQLiteDatabase db;
private SQLiteStatement insertStatement;



private String DB_Table = "trainingsplan";


private String INSERT = "insert into " + DB_Table
+ "(zweckkuerzel,aktuellertp,zweck)" + "values (?,?,?)";

它说错误出现在 select 语句中。

private String SEL_ROW = "select zweckkuerzel,aktuellertp,zweck from "
+ DB_Table;

private String CREATE_TABLE = "create table " + DB_Table
+ "(zweckkuerzel String, "
+ "aktuellertp String NOT NULL, "
+ "zweck String)";

private String CREATE_INDEX = "create index if not exists " + DB_Table
+ "_ind " + "ON " + DB_Table + " (zweckkuerzel)";

在这里我创建了我的 Dao 和 Tabel

    TrainingsplanDao trainingsDao= new TrainingsplanDao(db);
trainingsDao.createTable();
trainingsDao.fillTable();

这是我的 Dao 的构造器

public TrainingsplanDao(SQLiteDatabase db) {

this.db = db;
try {
insertStatement = db.compileStatement(INSERT);
Log.d("ANDRO VEGI", "Create INSERT product");
} catch (SQLException e) {
Log.d("ANDRO VEGI", "NO Database, NO INSERT TrainingsplanDao()");
}
}

最佳答案

它清楚地表明在数据库中找不到名为trainingsplan的表。请确保它确实以相同的名称存在。

关于java - SQLite异常: no such table: trainingsplan (code 1) while compiling: select statment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22450934/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com