sqlstr = "select * from t_user where f_name='" + name + "' and f_passwd ='" + passwd + "'";
result = query.exec(sqlstr);
qDebug() << "result " << result;
result = query.result();
if(!result || query.size() != 1) {
QMessageBox::information(NULL, tr("User login"), tr("User login falise!"));
qDebug() << "result " << result << " ; size " << query.size();
while(query.next())
{
qDebug() << query.value(0).toInt() << query.value(1).toString() << query.value(2).toString();
}
qDebug() << sqlstr;
return false;
}
库里是有数据的,
result = query.exec(sqlstr); 返回的是 false, 应该返回 true 才对吧
query.size() 返回的是 -1 查到一条数据,应该返回 1 才对吧
result 是 false, size() 返回 -1 的情况下, 可以输出一条数据, 查询应该是成功的.
我用的是SQLITE数据库, 请问, 这种情况下,怎么判断是否查询成功,