QSqlQuery::value: not positioned on a valid record
来源:互联网 发布:c语言输入保留两位小数 编辑:程序博客网 时间:2024/05/29 19:30
在使用QSqlQuery查询数据并用query的结果value出现QSqlQuery::value: not positioned on a valid record错误
QSqlQuery query;
query.prepare("select id,name from employee where name like :inputName");
query.bindValue(":inputName",str);
query.exec();
// QString namestr=query.value(1).toString(); //如果这句放在这里的话出现上述错误
if(query.first())
{
QString namestr=query.value(1).toString(); //放在此处则正确
emit searchButton_clicked(namestr);
}
解决方法:QSqlQuery返回的数据集,record是停在第一条记录之前的。所以,你获得数据集后,必须执行next()或first()到第一条记录,这时候record才是有效的。否则,exec完直接value肯定报这个错
0 0
- QSqlQuery::value: not positioned on a valid record
- QSqlQuery::value: not positioned on a valid record
- QSqlQuery::value: not positioned on a valid record
- QSqlQuery::value: not positioned on a valid record
- QSqlQuery::value: not positioned on a valid record 的错误的解决方法
- qt关于not positioned on a valid record
- Qt数据库操作报错not positioned on a valid record
- '{DependencyProperty.UnsetValue}' is not a valid value for the '.........Background'
- Dynamics CRM2016 The value of field on record of type entity is outside the valid range问题的解决方法
- Positioned Update not supported.
- Positioned Update not supported
- MVC checkbox报错The value 'on' is not valid for <propertyname>.
- BW:Enter a valid value
- not a valid SHA1
- DependencyProperty.UnsetValue}' is not a valid value for property 'Background' 的错误原因
- WPF 错误:DependencyProperty.UnsetValue}' is not a valid value for property 'Background'
- ERROR spi.SqlExceptionHelper : 'Infinity' is not a valid numeric or approximate numeric value 问题解决
- XE6打开XE5工程 false is not a valid integer value
- Linux VIP(虚拟IP)配置后,无法ping通的问题处理
- webstorm注册序列号和那啥
- C++学习笔记10-面向对象
- 不适用临时表进行分页,筛选,查询,避免高并发的方法。
- .net 文件上传至数据库二进制字段 及读取操作。
- QSqlQuery::value: not positioned on a valid record
- 使用HTML5的十大原因
- css hack IE兼容调试小结(Webstorm、VS2010),有图有真相,研究了一中午
- 服务器如何生成ID
- YUV内存里的存放顺序
- 关于完成端口,部分内容摘要
- cocos2d-x 3.1.1 学习笔记[14] UserDefault 用户数据存储
- 怎么马航客机又出问题的啦
- json数据 填充遍历表格行列 jQuery