我正在数据库 order.db 中创建一个名为 order 的表。在执行函数调用“database.execSQL(DATABASE_CREATE)”期间出现错误。
错误如下:
04-17 02:06:35.014: E/AndroidRuntime(4612): android.database.sqlite.SQLiteException: near "order": syntax error (code 1): , while compiling: create table order ( _id integer primary key autoincrement, orderName text not null, orderCommission text not null, orderDate text not null, orderSlot text not null, orderGain text not null, orderNO text not null, orderValue text not null);
package com.shoaib.lotteryerp.helper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class MySQLiteHelperOrder extends SQLiteOpenHelper {
public static final String TABLE_ORDER = "Order";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_NAME = "orderName";
public static final String COLUMN_DATE="orderDate";
public static final String COLUMN_ORDERNO="orderNO";
public static final String COLUMN_SLOT="orderSlot";
public static final String COLUMN_ORDERVALUE="orderValue";
public static final String COLUMN_COMMISSION="orderCommission";
public static final String COLUMN_GAIN="orderGain";
private static final String DATABASE_NAME = "order.db";
private static final int DATABASE_VERSION = 2;
// Database creation sql statement
private static final String DATABASE_CREATE = "create table "
+ TABLE_ORDER + "(" + COLUMN_ID
+ " integer primary key autoincrement, " + COLUMN_NAME
+ " text not null, " + COLUMN_COMMISSION + " text not null, "
+ COLUMN_DATE + " text not null, "
+ COLUMN_SLOT + " text not null, "
+ COLUMN_GAIN + " text not null, "
+ COLUMN_ORDERNO + " text not null, " + COLUMN_ORDERVALUE
+ " text not null);";
MySQLiteHelperOrder(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(MySQLiteHelperOrder.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ORDER);
onCreate(db);
}
}