2013-02-01 85 views
1

我總是得到這個錯誤。我認爲查詢是好的。什麼是問題?sqlite查詢中的語法錯誤?

「引起:android.database.sqlite.SQLiteException:near」to「:語法錯誤:,編譯時:create table消息(_id integer,msgdesc text,date timestamp not null,整數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); 


} 
+1

也許「to」是保留名? – dilix

+0

我在控制檯中嘗試我的sql語句並在記事本++中編輯它們。這顯示我什麼話是保留的,所以我繞過程序崩潰和其他錯誤,需要一些時間來調試 – Zaiborg

回答