0

Java で sqlite データベースの varchar を更新するのに問題があります。このソースを実行すると、エラーが発生します。文字列 a を文字列 b に更新したい。

これは私のソースです:

public void onClick (View v){
String a = "Test1";
String b = "Test2";

    db = openOrCreateDatabase("MyDB", MODE_PRIVATE, null); 
                 ContentValues values = new ContentValues();
                 values.put("Level1", b);
                     db.update("Game", values, a, null);
                 db.close();
}

そして、これは私のエラーです:

Error updating Level1=Test2 using update Game SET Level1=? WHERE Test1.

誰かが私を助けることができますか?ありがとう!

4

2 に答える 2

0

update Game SET Level1=? WHERE Test1.

Test1 はどこにありますか? update ステートメントの条件部分はどこにありますか。次のようなものを期待しています:

update Game SET Level1=? WHERE ColumnName='Test1'


このウェブサイトからの引用:

If the UPDATE statement does not have a WHERE clause, all rows in the table are modified by the UPDATE. Otherwise, the UPDATE affects only those rows for which the result of evaluating the WHERE clause expression as a boolean expression is true.

それ自体の文字列は決してブール式ではありません。

于 2013-04-10T18:30:39.467 に答える