yannifan
19th August 2011, 11:38
Hi
I have a simple SQL insertion and select statements as shown in the code below.
QString name_1, number_1;
QSqlQuery query(iLbsDb);
query.prepare("insert into contacttable (name, number) values(?,?)");
query.bindValue(":name", name);
query.bindValue(":number", number);
if(query.exec())
{
QSqlQuery query_1(iLbsDb);
query_1.prepare("select * from contacttable");
if(query_1.exec())
{
while(query_1.next())
{
QSqlRecord rec = query_1.record();
int c;
if(rec.isEmpty() != true)
c = rec.indexOf("number");
if(query_1.isValid())
name_1 = query_1.value( c).toString();
//number_1 = query_1.value(1).toString();
qDebug("name %s", name_1);
//qDebug("number %s", number_1);
}
}
return true;
}
else
return false;
Im receiving the error
sStopped: Illegal instruction (Signal SIGILL).
at the instruction
name_1 = query_1.value( c).toString();
Unable to figure out what might be the problem.
I tried
QVariant t = query_1.value(c);
QString s = t.toString();
The variable t seem to have been populated, but the error occurs in the toString line
Pls help
Thanks
I have a simple SQL insertion and select statements as shown in the code below.
QString name_1, number_1;
QSqlQuery query(iLbsDb);
query.prepare("insert into contacttable (name, number) values(?,?)");
query.bindValue(":name", name);
query.bindValue(":number", number);
if(query.exec())
{
QSqlQuery query_1(iLbsDb);
query_1.prepare("select * from contacttable");
if(query_1.exec())
{
while(query_1.next())
{
QSqlRecord rec = query_1.record();
int c;
if(rec.isEmpty() != true)
c = rec.indexOf("number");
if(query_1.isValid())
name_1 = query_1.value( c).toString();
//number_1 = query_1.value(1).toString();
qDebug("name %s", name_1);
//qDebug("number %s", number_1);
}
}
return true;
}
else
return false;
Im receiving the error
sStopped: Illegal instruction (Signal SIGILL).
at the instruction
name_1 = query_1.value( c).toString();
Unable to figure out what might be the problem.
I tried
QVariant t = query_1.value(c);
QString s = t.toString();
The variable t seem to have been populated, but the error occurs in the toString line
Pls help
Thanks