1

常にこのエラーが発生します。クエリは大丈夫だと思います。何が問題ですか?

「原因: android.database.sqlite.SQLiteException: "to" の近く: 構文エラー: 、コンパイル中: テーブルの作成 Messages(_id integer , msgdesc text ,date timestamp not null, createdby integer not null, to integer not null); "

これは私のコードです:

public class ContactListDB extends SQLiteOpenHelper {


private static final int DATABASE_VERSION = 2;
private static final String DATABASE_NAME = "MobileMerch";

// Database creation SQL statement
private static final String CREATE_MERCH  = "create table Merchendiser" +
        "(_id integer primary key, name text not null,surname text not null,username text not null);";

// Database creation SQL statement
private static final String CREATE_MESSAGES = "create table Messages" +
        "(_id integer , msgdesc text ,date timestamp  not null, createdby integer not null, to integer not null);";



public ContactListDB(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}    

public void onCreate(SQLiteDatabase db) {

    db.execSQL(CREATE_MERCH);
    db.execSQL(CREATE_MESSAGES);


}
4

1 に答える 1

5

TO予約語です。列の名前を変更するか(推奨)、二重引用符で囲んでエスケープします(例"to")。

参照:http ://www.sqlite.org/lang_keywords.html

于 2013-02-01T07:20:57.080 に答える