I have a problem retrieving data from a sqllite database, lasterror().text returns with "No query Unable to fetch row", running the query directly in the database gives me no issues and works.
QString SQL
= "SELECT groups.name FROM groups " "INNER JOIN shiptypes ON groups.id = shiptypes.groupid "
"INNER JOIN ships ON shiptypes.id = ships.shiptype "
"INNER JOIN reports ON ships.id = reports.ship "
"INNER JOIN posts ON posts.id = reports.postid "
"WHERE posts.stamp = :stamp";
groupQuery.prepare(SQL);
groupQuery.bindValue(":stamp",reportKey);
if (!groupQuery.exec()) {
errorCode = 510;
error = true;
errorMessage = groupQuery.lastError().text();
} else {
while (groupQuery.next()) {
groups.append(groupQuery.value(0).toString());
}
}
QStringList groups;
QString SQL = "SELECT groups.name FROM groups "
"INNER JOIN shiptypes ON groups.id = shiptypes.groupid "
"INNER JOIN ships ON shiptypes.id = ships.shiptype "
"INNER JOIN reports ON ships.id = reports.ship "
"INNER JOIN posts ON posts.id = reports.postid "
"WHERE posts.stamp = :stamp";
QSqlQuery groupQuery(connection);
groupQuery.prepare(SQL);
groupQuery.bindValue(":stamp",reportKey);
if (!groupQuery.exec()) {
errorCode = 510;
error = true;
errorMessage = groupQuery.lastError().text();
} else {
while (groupQuery.next()) {
groups.append(groupQuery.value(0).toString());
}
}
To copy to clipboard, switch view to plain text mode
I've checked reportKey and it contains the correct value for WHERE clause, so that isn't an issue. I've also checked database connection and it connects successfully with database. Any suggestions?
Bookmarks