本人在服务端用中文查询SQL中的字段,为什么查不到。改用数字和字母就OK。在服务端向SQL数据库添加中文,sql数据库记录得是“???”为什么?
一下是查询的代码:
QString name=this->lineEdit5->text();
if (this->lineEdit5->text() == "")
{
QMessageBox::warning(this,"","null!");
return;
}
QString sql = "select id,xh,xm,xb,jg,zy from student where xh='"+name+"'";
qr.exec(sql);
if (qr.next())
{
int i = 0;
do
{
table1->setText(i,0,QString::fromUtf8(qr.value(0).toString()));
table1->setText(i,1,QString::fromUtf8(qr.value(1).toString()));
table1->setText(i,2,QString::fromUtf8(qr.value(2).toString()));
table1->setText(i,3,QString::fromUtf8(qr.value(3).toString()));
table1->setText(i,4,QString::fromUtf8(qr.value(4).toString()));
table1->setText(i,5,QString::fromUtf8(qr.value(5).toString()));
i++;
}while(qr.next());