Boolean variable always returning false
bool Payment::checkUniqueIdentifier(const QString &invoice)
{
qDebug() << "entering Payment: check if the invoice has an associated unique identifier or not for the invoice=" + invoice;
QSqlQuery query(m_storageUserManager->database());
query.prepare("SELECT invoice FROM " + m_invoiceInfoTable + "WHERE invoice=:invoice");
query.bindValue(": invoice", invoice);
query.exec();
query.first();
bool tmp;
tmp = query.isValid();
return tmp;
}
Hi this boolean variable is always returned as false, Can you tell me what could be the possible problem I was using this function as follows
if(payment->checkUniqueIdentifier("invoice1"))
qDebug() << "It has a unique Identifier";
else
qDebug() << "It dont have a unique Identifier";
开发者_StackOverflowThank you Regards, Puneet
There's no space before the where in the query. The table name and where have been concatenated and it reads
SELECT invoice FROM m_invoiceInfoTableWHERE invoice=:invoice
精彩评论