开发者

SQLite Insert fails silently on BlackBerry

开发者 https://www.devze.com 2023-03-18 06:10 出处:网络
I\'m trying to insert some data into an existing SQLite table. The table and the database were created using the same API, but for some reason insertion doesn\'t work, and never gives me an error mess

I'm trying to insert some data into an existing SQLite table. The table and the database were created using the same API, but for some reason insertion doesn't work, and never gives me an error message.

I'm testing this on the BlackBerry 9550 simulator.

Here is my query:

final String insertQuery
    = "INSERT INTO 'Auth'( "
        + "'" + USER_ID_KEY + "', "
        + "'" + USER_NAME_KEY + "', "
        + "'" + USER_PASSWORD_KEY + "' ) "
        + "VALUES ( "
        + userId + ", "
        + "'" + username + "', "
        + "'" + password + "' ) ";

And the code I use to run it:

final Statement insertOrUpdateStatement;

insertOrUpdateStatement
    = database.createStatement(insertQuery);

insertOrUpdateStatement.prepare();
insertOrUpdateStatement.execute();
insertOrUpdateStatement.close();

It executes just fine, I get no error messages, but the data is never inserted. I've used 3 different SQLite browsers and the BlackBerry API to confirm this.

I've tried using explicit transactions, too, and that doesn't work either. I've searched for similar problems, tried lots of variations on t开发者_如何学编程his code, and nothing works. Help?


I'm assuming this is because you have an excess of single quotes around your table and fields. Have you tried to remove the quotes from the insert syntax, e.g.

final String insertQuery
         = "INSERT INTO Auth(USER_ID_KEY,USER_ID_KEY,USER_PASSWORD_KEY) "
            + "VALUES ("
            + userId + ", "
            + "'" + username + "', "
            + "'" + password + "' ) ";
0

精彩评论

暂无评论...
验证码 换一张
取 消