public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE " + TABLE_INFO + "(" +
COLUMN_ID + " INTEGER PRIMARY KEY " +
COLUMN_DATE + " TEXT " +
COLUMN_DOCNAME + " TEXT " +
COLUMN_SYMP + " TEXT " +
COLUMN_DIGNO + " TEXT " +
COLUMN_MEDS + " TEXT " +
");";
db.execSQL(query);
这有什么问题?获取AndroidRuntime:
FATAL EXCEPTION: main android.database.sqlite.SQLiteException:
near "date": syntax error: ,
while compiling: CREATE TABLE info(_id INTEGER PRIMARY KEY
date TEXT
docName TEXT symp TEXT digno TEXT meds TEXT );
错误。
请帮忙
答案 0 :(得分:1)
每个列后的查询中都有逗号,请更改查询字符串,如下所示:
String query = "CREATE TABLE " + TABLE_INFO + "(" +
COLUMN_ID + " INTEGER PRIMARY KEY, " +
COLUMN_DATE + " TEXT, " +
COLUMN_DOCNAME + " TEXT, " +
COLUMN_SYMP + " TEXT, " +
COLUMN_DIGNO + " TEXT, " +
COLUMN_MEDS + " TEXT " +
");";
答案 1 :(得分:0)
你缺少逗号。添加它。