开发者

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";
开发者_StackOverflow

Thank 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜