If you modify your codes to the following:
int ProductsForm::categoryIdByName(const QString& name)
{
categories.
exec(QString("SELECT id FROM Categories WHERE name='%1'").
arg(name
));
if(categories.size()==-1)
{
qDebug() << "error";
return 1;
}
.....
}
int ProductsForm::categoryIdByName(const QString& name)
{
QSqlQuery categories(model->database());
categories.exec(QString("SELECT id FROM Categories WHERE name='%1'").arg(name));
if(categories.size()==-1)
{
qDebug() << "error";
return 1;
}
.....
}
To copy to clipboard, switch view to plain text mode
is categories.size() value still -1 ?
Bookmarks