Hi, I have the code:
{
Q_ASSERT(strPicPath.size()>0); // assertion test
// use query
/*
QSqlQuery useQuery("USE merchandize;");
qDebug() << useQuery.lastError(); // debug
*/
// query string;
QString queryString
("SELECT * FROM `eros`.`merchandize` WHERE PicPath=\"%1\";");
queryString=queryString.arg(strPicPath);
qDebug() << "queryString:" << queryString; // debug
QSqlQuery query
(queryString
);
// executes sql query //Q_ASSERT(query.value(iMerchandizeFieldNAME).toString().size()>0); // assertion test
qDebug() << query.lastError(); // debug: shows error
qDebug() << query.value(iMerchandizeFieldNAME).toString(); // debug
return(query.value(iMerchandizeFieldNAME).toString()); // returns merchandize name
}
QString CMerchandizeBrowser::getMerchandizeName(QString strPicPath)
{
Q_ASSERT(strPicPath.size()>0); // assertion test
// use query
/*
QSqlQuery useQuery("USE merchandize;");
qDebug() << useQuery.lastError(); // debug
*/
// query string;
QString queryString("SELECT * FROM `eros`.`merchandize` WHERE PicPath=\"%1\";");
queryString=queryString.arg(strPicPath);
qDebug() << "queryString:" << queryString; // debug
QSqlQuery query(queryString); // executes sql query
//Q_ASSERT(query.value(iMerchandizeFieldNAME).toString().size()>0); // assertion test
qDebug() << query.lastError(); // debug: shows error
qDebug() << query.value(iMerchandizeFieldNAME).toString(); // debug
return(query.value(iMerchandizeFieldNAME).toString()); // returns merchandize name
}
To copy to clipboard, switch view to plain text mode
and after qDebug() << query.lastError() I get:
warning: QSqlError(-1, "", "")
To copy to clipboard, switch view to plain text mode
The connection to database is ok, I've double checked. What is wrong, please help!
Bookmarks