Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
11-22-2012 04:34 PM
I am trying for 2 hours to solve this problem. I am building a basic application, which uses SQLite database using SqlDataAccess wrapper. This is my database creation code, which gets executed only if db/database.db file does not exist.
// Create an SqlDataAccess object SqlDataAccess sda("db/database.db"); sda.execute("CREATE TABLE Profiles (profile_id INTEGER PRIMARY KEY, profile_name TEXT, is_sel INTEGER, max_number INTEGER, number_to_generate INTEGER);"); sda.execute("INSERT INTO Profiles (profile_name, is_sel, max_number, number_to_generate) VALUES ('Test', 1, 39, 7);"); sda.disconnect();
Otherwise I select the data in table and display it in QML. The select code:
SqlDataAccess sda("db/database.db"); QVariant list = sda.execute("SELECT * FROM Profiles;");
But I never get to this point. SELECT always returns empty QVariant, which is normal because data is never inserted. I tried inserting data immediately before SELECT, but also nothing. The INSERT clause is valid and does not display any error (using DataAccessError) and is executed successfully. The schema is created successfully, but the data is never inserted.
According to this example it should work: https://developer.blackberry.com/cascades/document
What am I doing wrong?
12-04-2012 09:12 AM
I think I had similar problem, try without a semicolon at the end:
just: "INSERT INTO table (col,col2,col3) VALUES (3,4,5)"
Another thing, before continuing it is good to check if previous operation was successfull:
12-04-2012 12:43 PM
Thank you for your reply. I have tried all queries with and without semicolon, does not make any difference. And I also tested each query with sda.hasError() function, like you said, but there are no errors at all. Just the data is not saved.
12-04-2012 01:07 PM - edited 12-04-2012 01:09 PM
Are you sure that the result of SELECT query is correct? Did you cast it to QVariantList? Maybe check
12-04-2012 01:14 PM
I have tested the SELECT query many times, even in online SQL validators. The select statement is not the problem, because the INSERT is not performed. I can also check this by filesize, because the database file does not change size after creating tables. I cannot imagine that 5 selects do not add a single byte to the database.
12-04-2012 01:20 PM
12-04-2012 01:22 PM
12-04-2012 02:50 PM
For debugging purposes scp file over to your Linux (may work with windows) machine and download apt-get with ubuntu) sqlite3 This way you can verify that your tables are there, schema is as you think it is, and see what records are there.
.tables // will show tables
.schema <tablename> // show you the schema
select * from <tablename>; // note semicolin fo rthis command only