Results 1 to 8 of 8

Thread: Illegal instruction (Signal SIGILL) for QSqlQuery

  1. #1

    Default Illegal instruction (Signal SIGILL) for QSqlQuery

    Hi

    I have a simple SQL insertion and select statements as shown in the code below.
    Qt Code:
    1. QString name_1, number_1;
    2. QSqlQuery query(iLbsDb);
    3. query.prepare("insert into contacttable (name, number) values(?,?)");
    4. query.bindValue(":name", name);
    5. query.bindValue(":number", number);
    6.  
    7. if(query.exec())
    8. {
    9. QSqlQuery query_1(iLbsDb);
    10. query_1.prepare("select * from contacttable");
    11.  
    12. if(query_1.exec())
    13. {
    14. while(query_1.next())
    15. {
    16. QSqlRecord rec = query_1.record();
    17. int c;
    18. if(rec.isEmpty() != true)
    19. c = rec.indexOf("number");
    20. if(query_1.isValid())
    21. name_1 = query_1.value( c).toString();
    22. //number_1 = query_1.value(1).toString();
    23. qDebug("name %s", name_1);
    24. //qDebug("number %s", number_1);
    25. }
    26. }
    27. return true;
    28. }
    29. else
    30. return false;
    To copy to clipboard, switch view to plain text mode 
    Im receiving the error
    sStopped: Illegal instruction (Signal SIGILL).
    at the instruction
    Qt Code:
    1. name_1 = query_1.value( c).toString();
    To copy to clipboard, switch view to plain text mode 
    Unable to figure out what might be the problem.

    I tried
    Qt Code:
    1. QVariant t = query_1.value(c);
    2. QString s = t.toString();
    To copy to clipboard, switch view to plain text mode 

    The variable t seem to have been populated, but the error occurs in the toString line

    Pls help

    Thanks
    Last edited by wysota; 19th August 2011 at 14:26. Reason: changed [quote] to [code]

  2. #2
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    If you are true and the error come from the QVariant::toString() method maybe you should test the conversion before doing it :
    QVariant::canConvert() it should give you some ideas.

  3. #3

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    Changed the code to

    Qt Code:
    1. QSqlQuery query;
    2. query.prepare("select name, number from contacttable");
    3. if(query.exec())
    4. {
    5. QSqlRecord rec = query.record();
    6. int c = rec.indexOf("name");
    7. while(query.next())
    8. {
    9. if(query.isValid()==true)
    10.  
    11. {
    12. QVariant t = query.value(c);
    13. if(t.canConvert<QString>() == true && t.isNull() == false)
    14. {
    15. qDebug("name %s", t.toString());
    16. s = t.value<QString>();
    17. //s=t.toString();
    18. qDebug("name %s",s);
    19. }
    20. }
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Neither string conversion functions work properly
    Last edited by wysota; 19th August 2011 at 14:27. Reason: changed [quote] to [code]

  4. #4
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    Put some debug on your code.
    Something like

    Qt Code:
    1. QVariant t = query.value(c);
    2. qDebug() << c << t;
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    Check the value of 'c'. Maybe it is -1.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    The qDebug signature from the docs:
    void qDebug ( const char * msg, ... )
    It is looking for a char* array, so I think you have to use one of the following:
    Qt Code:
    1. qDebug("name %s", qPrintable(name_1));
    2. qDebug("name %s", name_1.toAscii().data());
    To copy to clipboard, switch view to plain text mode 
    Or if you include <QDebug>:
    Qt Code:
    1. qDebug() << "name" << name_1
    To copy to clipboard, switch view to plain text mode 

  7. #7

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    Thanks problem is solved.

    Variable 'c' had a proper value.
    qDebug("%s", name);
    seemed to be the problem.
    It worked with
    qDebug() << name;


    Thanks again

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Illegal instruction (Signal SIGILL) for QSqlQuery

    Your compiler probably warned you about it during compilation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 18th July 2011, 12:12
  2. QWizard produces SIGILL
    By lauwe in forum Qt Programming
    Replies: 3
    Last Post: 6th March 2011, 19:46
  3. Replies: 1
    Last Post: 1st April 2010, 07:54
  4. XML processing instruction
    By mattia in forum Newbie
    Replies: 1
    Last Post: 26th February 2008, 11:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.