• 4327阅读
  • 2回复

query  加了where就搜不到了 [复制链接]

上一主题 下一主题
离线zjy6310516
 

只看楼主 正序阅读 楼主  发表于: 2020-11-17

QSqlQuery  query;      
QString  str1=QString("select *from text.case where name='陈凯'   ");        
query.exec(str1);        
qDebug()<<query.isActive()<<endl;  //true      
qDebug()<<query.isSelect()<<endl;  //true
qDebug(<<query.next()<<endl;  //false;                
QString name=query.value(0).toString();    
QString sex=query.value(1).toString();        
QString age=query.value(2).toString();

但是去掉where name=。。。就可以搜索到了
离线20091001753

只看该作者 2楼 发表于: 2020-11-17
u8"select *from text.case where name='陈凯'   "

含有中文,前面一律加 u8
(づ ̄ 3 ̄)づ
离线clickto

只看该作者 1楼 发表于: 2020-11-17
1、因为你有中文硬编码,所以,你的数据库所使用的编码和你cpp所使用的编码是否一致?
2、呃,,,,,你的数据库里有木有要搜索的内容?
快速回复
限100 字节
 
上一个 下一个