09-03-2010 08:33 AM
While I'm inserting a set of string values to SQLite database in my Blackberry application, I'm getting this Exception.
net.rim.device.api.dataabse.DatabaseException: INSERT INTO SODetails(Wono, Ettc, Time, Comments, City, Shipname) Values ('029648', '8.00', 'A0600', 'Problem', 'Edmonton', 'WENDY'S'
QL logic error or missing database.
Can anyone help?
Solved! Go to Solution.
09-03-2010 08:38 AM
First Download the SQLite Manager and Install it. then Check Ur Database is Successfull created or not. then try to insert the values.
And U made a mistake in the Query. So check Ur Query also. check the Demo Application which is provide by JDE 5.0.
--------------------------------------------------
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution
09-03-2010 12:12 PM
My guess is that you are building your SQL query by directly inserting the values to the SQL query string. When a value has an embedded apostrophe (WENDY'S), this causes a syntax error in the SQL. Because SQLite cannot understand the statement, the error messages can be somewhat random.
The solution is to prepare a Statement that has parameters instead of actual values and then bind the values to the statement.:
Statement s = db.createStatement(
"INSERT INTO SODetails(Wono, Ettc, Time, Comments, City, Shipname) " +
"VALUES (?, ?, ?, ?, ?, ?)"
);
s.prepare();
s.bind(1, "029648");
s.bind(2, "8.00");
s.bind(3, "A0600");
s.bind(4, "Problem");
s.bind(5, "Edmonton");
s.bind(6, "WENDY'S");
s.execute();
09-06-2010 01:22 AM
INSERT INTO SODetails(Wono, Ettc, Time, Comments, City, Shipname) VALUES ('029648', '8.00', 'A0600', 'Problem', 'Edmonton', 'WENDYS')
should work since SQLite will not accept a value with a single quote inside it.