gpt4 book ai didi

android - 创建表语句中的 Sqlite 异常

转载 作者:太空宇宙 更新时间:2023-11-03 12:22:22 26 4
gpt4 key购买 nike

我有一个包含两个表的数据库。最近,我插入了一个新行(key_today),我得到以下 sqlite exception :

android.database.sqlite.SQLiteException: near "text": syntax error: create table tasks (_id integer primary key autoincrement, title text not null,location text not null, body text not null ,  goaldate text not null ,  absolutedate text not null ,  currentdate text not null ,  prio text not null,  done text not null,  category text not null,  timespent text not null,  pososto text not null,  father text not null,  check text not null );

我已经更改了方法以包含新行,但我真的找不到我做错了什么。

这是我的代码,提前谢谢你

public static final String KEY_TITLE = "title";
public static final String KEY_BODY = "body";
public static final String KEY_ROWID = "_id";
public static final String KEY_FATHER="father";//father's id
public static final String KEY_location = "location";
public static final String KEY_GOAL_DATE = "goaldate";
public static final String KEY_ABSOLUTE_DATE = "absolutedate";
public static final String KEY_DATE_CURRENT = "currentdate";
public static final String KEY_PRIO= "prio";
public static final String KEY_DONE = "done";
public static final String KEY_CATEGORY = "category";
public static final String KEY_TIME_SPEND = "timespent";
public static final String KEY_POSOSTO = "pososto";
public static final String KEY_TODAY= "check";

public static final String KEY_STITLE = "atitle";
public static final String KEY_ROID = "_id";
public static final String KEY_SCOLOR = "color";


private static final String TAG = "ListDatabase";
/**
* @uml.property name="mDbHelper"
* @uml.associationEnd
*/
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;

/**
* Creating database tables
*/
private static final String DATABASE_CREATE =
"create table tasks (_id integer primary key autoincrement, "

+ "title text not null,"
+"location text not null, "
+ "body text not null , "
+" goaldate text not null , "
+" absolutedate text not null , "
+" currentdate text not null , "
+" prio text not null, "
+" done text not null, "
+" category text not null, "
+" timespent text not null, "
+" pososto text not null, "
+" father text not null, "
+" check text not null );";

最佳答案

检查a reserved word in SQLite ;尝试重命名该列或将其放在 SQL 语句中的(转义)双引号中。

关于android - 创建表语句中的 Sqlite 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11726231/

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