2011-09-28 137 views
0

這是錯誤:失敗1(無法識別的令牌: 「1295980589.jpg」)上0x2a6530

09-28 17:48:03.830: ERROR/Database(1485): Failure 1 (unrecognized token: "1295980589.jpg") on 0x2a6530 when preparing 'INSERT INTO bookmarks (id, title, image1File) VALUES (2014, 'Hilton Craigendarroch, '1295980589.jpg')'. 

這是代碼:

this.db.execSQL("INSERT INTO " + CMSConstants.BOOKMARKS + " (" + CMSConstants.ID + ", " + CMSConstants.TITLE + ", " + CMSConstants.IMAGE1_FILE + ") VALUES (" + id + ", '" + title + ", '" + image + "')"); 

問題出在哪裏? 希望有人能幫助我....

感謝名單 newone

回答

2

你錯過了在標題關閉單引號。你認爲圖像名稱的開頭報價是標題的結束報價。試試這個:

this.db.execSQL("INSERT INTO " 
    + CMSConstants.BOOKMARKS 
    + " (" 
    + CMSConstants.ID 
    + ", " 
    + CMSConstants.TITLE 
    + ", " 
    + CMSConstants.IMAGE1_FILE 
    + ") VALUES (" 
    + id 
    + ", '" 
    + title 
    + "', '" // <-- Note ' before , 
    + image 
    + "')"); 
1
this.db.execSQL("INSERT INTO " + CMSConstants.BOOKMARKS + " (" + CMSConstants.ID + ", " + CMSConstants.TITLE + ", " + CMSConstants.IMAGE1_FILE + ") VALUES (" + id + ", '" + title + "', '" + image + "')"); 

試試這個,你忘了一個 「'」

1

你錯過了關閉單引號的標題

試試這個

this.db.execSQL("INSERT INTO " + CMSConstants.BOOKMARKS + " (" + CMSConstants.ID + ", " + CMSConstants.TITLE + ", " + CMSConstants.IMAGE1_FILE + ") VALUES (" + id + ", '" + title + "', '" + image + "')"); 
相關問題