- yes
No
When I comment out the fllowing line, there is no more crash. But I need to delete the .db file created by the sqlite database before compiling again. If I don't do that, the crash occurs agin even if I comment the line.
Qt Code:
query.exec("create table callId (id int primary key,ext int,day varchar(10),moment varchar(5),duree int,transfer int,transferExist int,cosExist int,number int,cos int)");To copy to clipboard, switch view to plain text mode
Other observations:
[/QUOTE]
- It is unusual that, in a table with only two varchar fields, you insert everything as a string. Sqlite should allow this, but you might consider fixing the inserts.
- Sqlite treats 'bool' as integers with 1 == true, 0 == false, not strings 'true' and 'false'. While it will store and retrieve these faithfully it will treat both as false (i.e. their value as integers is zero) in boolean expressions.
- Your table is defined with 10 columns (not 9) and you are trying to insert 9 values. The SQL is broken.
- Your second insert will fail with a duplicate key. Sqlite will not manufacture an id column value for you unless the column is declared "integer primary key autoincrement" (literally) and you either insert a NULL into the column, or omit the column from the insert.
- You should get into the habit of explicitly nominating columns in insert statements so that adding a column to a table does not break every existing insert. For example:
Qt Code:
create table a (id integer primary key autoincrement, b varchar(10)); insert into a (b) values ('Hello'); select * from a;To copy to clipboard, switch view to plain text mode- If you need the 'number' column to preserve the leading zeroes on your (I assume) phone numbers then you must use a varchar field.
Thank you ChrisW67. I've just applied all your remarks. they were really helpful. But, I still have a the error message.
Here is my code.
Qt Code:
query.exec("create table callId (id integer primary key autoincrement,ext int,day varchar(10),moment varchar(5),duree int,transfer int,transferExist bool,cosExist bool,number varchar(20),cos int)"); query.exec("insert into callId values(NULL, 3300,'2011-10-28','17:25',128,3333,0,1,0022921301074,NULL)"); query.exec("insert into callId values(NULL, 3310,'2011-10-29','00:29',128,NULL,1,0,002217780216,10)");To copy to clipboard, switch view to plain text mode
Thanks Norobro to have replied to me.





Reply With Quote
Bookmarks