Hello,
I have a QSqlQuery where query.isValid = false and query.size() = 0, but I can't figure out why. It was working fine a couple weeks ago (famous last words). I have checked and confirmed the following:
-DB is open.
-query.exec() = true
-query.lastError() = QSqlError("", "", "")
-SQL syntax is valid (query works fine and returns results when output with qDebug() and run in Sequel Pro; also changing or simplifying the query doesn't affect anything)
-There is data to be returned, so it is not that the query has no results (see above)
QString orderID
= appInfo
->orderID;
QString queryString
= "SELECT order_item.qty_ordered, order_item.sku, order_item.name, order_item.price FROM order_item JOIN order ON order_item.order_id = order.entity_id WHERE order_item.qty_ordered > 0 AND order.increment_id = '" + orderID
+ "';";
QSqlQuery query
(queryString,
QSqlDatabase::database("gx_db"));
// I have multiple DBs connected, just specifying which one here
while(query.next()) {
qDebug() << "Why isn't this showing up??";
QJsonObject obj;
obj.insert("qty", query.value("qty_ordered").toString());
obj.insert("sku", query.value("sku").toString());
obj.insert("description", query.value("name").toString());
obj.insert("salePrice", query.value("price").toString());
array.append(obj);
}
QString orderID = appInfo->orderID;
QString queryString = "SELECT order_item.qty_ordered, order_item.sku, order_item.name, order_item.price FROM order_item JOIN order ON order_item.order_id = order.entity_id WHERE order_item.qty_ordered > 0 AND order.increment_id = '" + orderID + "';";
QSqlQuery query(queryString, QSqlDatabase::database("gx_db")); // I have multiple DBs connected, just specifying which one here
while(query.next()) {
qDebug() << "Why isn't this showing up??";
QJsonObject obj;
obj.insert("qty", query.value("qty_ordered").toString());
obj.insert("sku", query.value("sku").toString());
obj.insert("description", query.value("name").toString());
obj.insert("salePrice", query.value("price").toString());
array.append(obj);
}
To copy to clipboard, switch view to plain text mode
Any ideas? I'm stumped.
Bookmarks