PDA

View Full Version : setText not working



MarkoSan
9th January 2006, 20:29
What is wrong with this code:


void CCustomerUpdateDialog::slotZipcodeChanged(int iIndex)
{
QSqlQuery retrieveCityNameQuery("SELECT * FROM kraj k WHERE k.POSTNA_STEVILKA="+m_pZipcode->currentText());
QSqlError error=retrieveCityNameQuery.lastError();
if(error.type()!=QSqlError::NoError)
{
qDebug() << retrieveCityNameQuery.lastError();
} else
{
m_pCity->setText(retrieveCityNameQuery.value(1).toString()) ;
}
};


I select a zip code of an city and in the QLineEdit should provide then after click the name of city with selected Zip Code. But, sql i generated ok (double check), QLineEdity still stays empty! Why?

jacek
9th January 2006, 20:33
You forgot to invoke QSqlQuery::next().

MarkoSan
9th January 2006, 20:56
LOL, f... amateur. :D Thanks man. :D

sunil.thaha
11th January 2006, 08:30
Use Prepared Queries whenever possible.
Or else you are giving chance for Sql Injection

MarkoSan
11th January 2006, 14:05
Yes, I''need sql injection. :D