KeineAhnung
23rd April 2014, 10:54
Hi again,
I keep getting the QSqlError(-1, "", "") return from lastError() after I try to select a row from a SQLite table. I checked the query buy using it directly in the SQLite table via the FireFox plugin. The connection to the database is also okay. The code I am using to get the line I have been using over and over and it always worked as intended. I just cannot figure out what the difference is here. Does anyone know what this error message means?
Here is the code that is not working:
if(conOpen()){ // here I open the connection to the db and get an output connected, so the connection is okay
QSqlQuery* query=new QSqlQuery(myDB);
query->prepare("SELECT * FROM chars WHERE type='steel' AND class='V2A'");
if(query->exec() && query->size() > 0){ // if I don't use the size() the next lines provides an error telling me that there is no value(1)
qDebug() << query->value(1).toString();
}else{
qDebug() << query->lastError(); // -> here I get the error QSqlError(-1, "", "")
}
conClose();
}else{
ui->log->append("No connection");
}
I keep getting the QSqlError(-1, "", "") return from lastError() after I try to select a row from a SQLite table. I checked the query buy using it directly in the SQLite table via the FireFox plugin. The connection to the database is also okay. The code I am using to get the line I have been using over and over and it always worked as intended. I just cannot figure out what the difference is here. Does anyone know what this error message means?
Here is the code that is not working:
if(conOpen()){ // here I open the connection to the db and get an output connected, so the connection is okay
QSqlQuery* query=new QSqlQuery(myDB);
query->prepare("SELECT * FROM chars WHERE type='steel' AND class='V2A'");
if(query->exec() && query->size() > 0){ // if I don't use the size() the next lines provides an error telling me that there is no value(1)
qDebug() << query->value(1).toString();
}else{
qDebug() << query->lastError(); // -> here I get the error QSqlError(-1, "", "")
}
conClose();
}else{
ui->log->append("No connection");
}