Please post the stack trace or at least the last line in the stack trace that is your code.
Please post the stack trace or at least the last line in the stack trace that is your code.
Unfortunately, there is no stack trace
Capturer.jpg
Is that a debug build? Do a "Build->Clean All", a "Build->Rebuild All" and Run
If that doesn't work, set a breakpoint and step through your program until it crashes.
Other than that, can't help with Windows. Sorry.
There is nothing in the lines you have posted that should cause anything like a program crash. (See below for reasons it won't work anyway)
- Rebuild the project from scratch: does the problem still occur?
- Comment out those lines: does the crash still occur?
- Single step through those lines, including stepping into the Qt code, and tell us exactly which causes the crash and how it arrived there?
Other observations:
- 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.
- 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.
Does the problem go away if you use ":memory:" as the database file name? That is make a transient, in-memory database.
Bookmarks