2010-02-24 55 views
0

我創造了這樣插入時得到sqlite異常?如何?

db.execSQL("CREATE TABLE "+TABLE_NAME+" (" 
    +_ID+" INTEGER PRIMARY KEY AUTOINCREMENT," 
    + TITLE+" TEXT UNIQUE," 
    + PUBLISHED+" DATETIME," 
    + CONTENT+" TEXT," 
    + RATERS+" TEXT," 
    + VIEWCOUNT+" TEXT," 
    + THUMBNAIL+" TEXT," 
    + FAVCOUNT+" TEXT," 
    + FAVSTAT+" INTEGER," 
    + LINKWEB+" TEXT);"); 

我有,當我嘗試在表中插入值異常的數據庫?

02-24 15:57:37.802: ERROR/DatabaseUtils(283): Writing exception to parcel 
02-24 15:57:37.802: ERROR/DatabaseUtils(283): android.database.sqlite.SQLiteException: table bru_tube has no column named linkweb: , while compiling: INSERT INTO bru_tube(content, favstat, title, thumbnail, linkweb, raters, viewcount, published, favcount) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?); 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteProgram.native_compile(Native Method) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1026) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1412) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1307) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at com.brownuniv.brutube.BruTube_Provider.insert(BruTube_Provider.java:82) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.content.ContentProvider$Transport.insert(ContentProvider.java:150) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:140) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at android.os.Binder.execTransact(Binder.java:287) 
02-24 15:57:37.802: ERROR/DatabaseUtils(283):  at dalvik.system.NativeStart.run(Native Method) 

如何解決?任何想法?

回答

3

您確定LINKWEB變量還包含文本「linkweb」嗎?也許是拼寫錯誤。您可以使用ADB連接到模擬器並查看數據庫 - 可能有幫助(請參閱this document)。

+0

退房我已經編輯了我的疑問句.. – Praveen 2010-02-24 10:30:27

+0

好了,同樣的答覆,其他列名... – 2010-02-24 10:37:43

+0

作爲托爾斯滕表示,要確保你有正確的表模式在你的數據庫中。從上面的鏈接中,查看「從遠程Shell檢查sqlite3數據庫」部分 – ccheneson 2010-02-24 11:53:32

1

結賬還有來自命令行模擬器或您的桌面上存在列「linkweb」在表中

0

使用sqlite3來驗證你正在努力實現的是正確的,有沒有語法錯誤。在表創建後驗證模式。

0

我認爲沒有任何列名稱linkweb。

0

我覺得你寫的文字後失蹤空間