2011-08-21 147 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