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 + "' ) ";
精彩评论