Home > Back-end >  QT with SQLITE databases
QT with SQLITE databases

Time:10-06

//button event
QSqlQuery query;
Query. The exec (" select * from the fileinfo ");
Bool result=query. Next ();
If (result==false)
Query. The exec (" create table the fileinfo (id, filename, status);" );
Query. The exec (" select id from the fileinfo ");
While (query. The next ())
Record_number_Line=query. The value (0). ToInt ();

QString insertdata="HTTP://https://bbs.csdn.net/topics/insert into the fileinfo (id, filename, status) values ('" + QString: : number (record_number_Line);
The insertdata +="', '" + QString: : fromAscii (values1) +"', '0'); ";
Query. The exec (insertdata);
QDebug () & lt;

//another button events:
QSqlQuery query;
//modify the file marked as not read
QString the updatedata="HTTP://https://bbs.csdn.net/topics/update the fileinfo set status='1' where id='" + QString: : number (record_number_Line) +"', ".
QDebug () & lt; Query. The exec (the updatedata);

Compile the results:

"Insert into the fileinfo (id, filename, status) values (' 8 ', 'J140809008', '0');"
"Update the fileinfo set status='1' where id='8';"
In the super terminal execution: sqlite3 SysInfo. Db
Sqlite> Select * from the fileinfo;
1 | J140808001 | 1
2 | J140808002 | 1
3 | J140808003 | 1
4 | J140808004 | 1
5 | J140808005 | 1
6 | J140808006 | 1
7 | J140808007 | 1
8 | J140809008 | 1
Sqlite>
Results no abnormal,

Will this code to use cross arm - Linux - GCC compiler generated after the arm architecture executable code is copied to the run on board:
"Insert into the fileinfo (id, filename, status) values (' 9 ', 'J700101009', '0');"
"Update the fileinfo set status='1' where id='9';"
Segmentation fault
The application blank screen,
Use super terminal execution on the ARM board again: sqlite3 SysInfo. Db
Sqlite> Select * from the fileinfo;
1 | J140808001 | 1
2 | J140808002 | 1
3 | J140808003 | 1
4 | J140808004 | 1
5 | J700101005 | 1
6 | J700101006 | 1
7 | J700101007 | 0
8 | J700101008 | 1
9 | J700101009 | 0
Sqlite> Update the fileinfo set status='1' where id='9';
Sqlite> Select * from the fileinfo;
1 | J140808001 | 1
2 | J140808002 | 1
3 | J140808003 | 1
4 | J140808004 | 1
5 | J700101005 | 1
6 | J700101006 | 1
7 | J700101007 | 0
8 | J700101008 | 1
9 | J700101009 | 1
Sqlite>
The question is: performs the update in QT, run on the PC it is normal, cross-compilation later when the update command on the ARM board Segmentation faul
But run on ARM board super terminal sqlite3 xx. The db update command when it is normal,
This is where errors, please?

QString (" delete from the updatedata=https://bbs.csdn.net/topics/QString the fileinfo where id='") + QString: : number (record_number_Line) + QString (";" );
The delete statement is the same mistake,
  • Related