I am trying to insert new data into a SQLite table.
I know for sure that the insertion code is correct because I use it for different tables and it works fine.
I know for sure that the database and the table are created and exist because I can see them in the SQLite Browser.
But something in the SQLite syntax of creation or insertion is wrong because I receive this exception:
SQL error or missing database
Here is my code:
CREATE TABLE IF NOT EXISTS Theory_answers ("questionID" INTEGER,"answerID" INTEGER,"answerText" TEXT, "isTrue" INTEGER);
INSERT INTO Theory_answers (questionID, answerID, answerText,isTrue) VALUES ("1","1",text,"0");
The INSERT OR IGNORE INTO statement ignores the error message. The SELECT statement shows that the last two statements did not modify the fourth row. Since SQLite version 3.7. 11 it is possible to insert multiple rows using one INSERT statement.
SQLite INSERT INTO Statement is used to add new rows of data into a table in the database.
Maximum Number Of Pages In A Database FileThe largest possible setting for SQLITE_MAX_PAGE_COUNT is 4294967294. When used with the maximum page size of 65536, this gives a maximum SQLite database size of about 281 terabytes. The max_page_count PRAGMA can be used to raise or lower this limit at run-time.
should this be....
VALUES ("1","1",text,"0") -> VALUES (1,1,'text',0)
Or
VALUES ("1","1","text","0") <-- if you need to double quote all values?
Looking at this link, it suggests inserts are done with single quote around the text and no quotes around the numbers...
sqlite> INSERT INTO Books(Id, Title, Author, ISBN) ...> VALUES(1, 'War and Peace', 'Leo Tolstoy', '978-0345472403');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With