Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
shruthi
Posts: 13
Registered: ‎06-08-2010
My Carrier: airtel
Accepted Solution

SQLite Logic Error

 

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':smileyfrustrated:QL logic error or missing database.

Can anyone help? 

Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010

Re: SQLite Logic Error

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

Please use plain text.
Developer
Ted_Hopp
Posts: 1,304
Registered: ‎01-21-2009

Re: SQLite Logic Error

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();



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Developer
apjustin
Posts: 37
Registered: ‎05-27-2010

Re: SQLite Logic Error

 

 

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.

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Please use plain text.