簡體   English   中英

當我嘗試在 SQLite Android Studio 上進行插入時出錯

[英]error when i try to do an insert on SQLite Android Studio

我不知道為什么在我的 SQL 數據庫中執行插入操作時會出現錯誤,創建表的代碼是:

 mydatabase.execSQL("CREATE TABLE IF NOT EXISTS " + TabellaSpese.TABLE_NAME + "(" + TabellaSpese.PRIMARYKEY + " INTERGER PRIMARY KEY AUTOINCREMENT," + TabellaSpese.IMPORTO + " LONG," +
            TabellaSpese.CATEGORIA + " TEXT," + TabellaSpese.DATA + " DATE," + TabellaSpese.NOTE + " TEXT);");

查詢是:

 ContentValues cv = new ContentValues();
    cv.put(TabellaSpese.IMPORTO,importo);
    cv.put(TabellaSpese.CATEGORIA,categoria);
    cv.put(TabellaSpese.DATA,UsefullFunction.getDate());
    cv.put(TabellaSpese.NOTE,note);
    return mydatabase.insert(TabellaSpese.TABLE_NAME,null,cv);

錯誤是:

E/SQLiteDatabase: Error inserting note=d data=13/01/2020 importo=5 categoria=arova
android.database.sqlite.SQLiteException: table Spese has no column named note (code 1 SQLITE_ERROR[1]): , while compiling: INSERT INTO Spese(note,data,importo,categoria) VALUES (?,?,?,?)

我找不到錯誤

看來您應該創建到新版本數據庫的遷移。 不只是增加它的版本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM