Qt mysql QSqlQuery QSqlRecord

Qt mysql查询结果处理

 

#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>


QSqlQuery query_sql = vcManageDatabaseObj->searchObjBySchoolNameAndNamePY(inputNameStr, inputIDCardStr, loginUserID);

if (query_sql.size()>0)
{
    while (query_sql.next())
    {
        QSqlRecord qResultRecord = query_sql.record();
        for (int fileIndex = 0; fileIndex<qResultRecord.count(); fileIndex++)
        {
            int id1=-1;
            QString indexFileName = qResultRecord.fieldName(fileIndex);
            if (indexFileName == "id")
            {
                id1 = query_sql.value(fileIndex).toString().toInt();
            }
        }
    }
}

 

Qt连接mysql,查询结果处理方法。

###############################

posted @ 2021-06-09 17:34  西北逍遥  阅读(754)  评论(0编辑  收藏  举报