Quote Originally Posted by saa7_go View Post
If you modify your codes to the following:
Qt Code:
  1. int ProductsForm::categoryIdByName(const QString& name)
  2. {
  3. QSqlQuery categories(model->database());
  4. categories.exec(QString("SELECT id FROM Categories WHERE name='%1'").arg(name));
  5. if(categories.size()==-1)
  6. {
  7. qDebug() << "error";
  8. return 1;
  9. }
  10. .....
  11. }
To copy to clipboard, switch view to plain text mode 

is categories.size() value still -1 ?
yesss...