2011-08-21 110 views
0
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; 
} 

你好这个布尔变量总是返回假的,你能告诉我,这可能是可能出现的问题 我是用这个函数如下布尔变量总是返回false

if(payment->checkUniqueIdentifier("invoice1")) 
    qDebug() << "It has a unique Identifier"; 
    else 
    qDebug() << "It dont have a unique Identifier"; 

谢谢 问候, Puneet

回答

6

在查询的哪里没有空间。表名和已级联,并读

SELECT invoice FROM m_invoiceInfoTableWHERE invoice=:invoice 
+0

感谢很多:) 这是一个愚蠢的错误 和感谢这样的快速回复:) – Puneet

+0

它总是最难调试自己的代码! – Ben