当前位置: 首页>>代码示例>>C++>>正文


C++ QSqlQuery::isValid方法代码示例

本文整理汇总了C++中QSqlQuery::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQuery::isValid方法的具体用法?C++ QSqlQuery::isValid怎么用?C++ QSqlQuery::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSqlQuery的用法示例。


在下文中一共展示了QSqlQuery::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setLastValues

  void ObjectRecord_Impl::setLastValues(const QSqlQuery& query, ProjectDatabase& projectDatabase)
  {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    Record_Impl::setLastValues(query, projectDatabase);

    QVariant value;

    value = query.value(ObjectRecordColumns::name);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastName = value.toString().toStdString();

    value = query.value(ObjectRecordColumns::displayName);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastDisplayName = value.toString().toStdString();

    value = query.value(ObjectRecordColumns::description);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastDescription = value.toString().toStdString();

    value = query.value(ObjectRecordColumns::timestampCreate);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastTimestampCreate = DateTime(value.toString().toStdString());

    value = query.value(ObjectRecordColumns::timestampLast);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastTimestampLast = DateTime(value.toString().toStdString());

    value = query.value(ObjectRecordColumns::uuidLast);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastUUIDLast = toUUID(value.toString().toStdString());
  }
开发者ID:ORNL-BTRIC,项目名称:OpenStudio,代码行数:34,代码来源:ObjectRecord.cpp

示例2: editRoom

/**
  *Edits the fields from selected room in Room table
  *@param room is a room class item
  *@param fetchquery is an sql query
  *@param query is an sql query
  */
void RoomManagement::editRoom(Room room)
{
         QSqlQuery query;
         QSqlQuery fetchquery;

         fetchquery = sqlMechanism.myQuery();
         fetchquery.prepare("SELECT * FROM RoomsReservation WHERE fkRoomId= :rNum");
         fetchquery.bindValue(":rNum",room.getRoomNumber());
         fetchquery.exec();

         fetchquery.next();
         if(fetchquery.isValid())
             {
                   QMessageBox::information(0,"Input Data Error","This room can't be edited.Reservation in progress");
             }
         else
             {
                    query = sqlMechanism.myQuery();
                    query.prepare("update Rooms SET RoomFloor= :rFloor, Capacity= :capacity WHERE RoomNumber=:rNum");
                    query.bindValue(":rNum",room.getRoomNumber());
                    query.bindValue(":rFloor",room.getRoomFloor());
                    query.bindValue(":capacity",room.getCapacity());
                    query.exec();
             }
 }
开发者ID:TheolZacharopoulos,项目名称:tl2hotel,代码行数:31,代码来源:roomManagement.cpp

示例3: compareValues

bool AlgorithmRecord_Impl::compareValues(const QSqlQuery& query) const {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    bool result = ObjectRecord_Impl::compareValues(query);

    QVariant value;

    value = query.value(AlgorithmRecordColumns::algorithmRecordType);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_algorithmRecordType == AlgorithmRecordType(value.toInt()));

    value = query.value(AlgorithmRecordColumns::complete);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_complete == value.toBool());

    value = query.value(AlgorithmRecordColumns::failed);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_failed == value.toBool());

    value = query.value(AlgorithmRecordColumns::iter);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_iter == value.toInt());

    return result;
}
开发者ID:jbl5088,项目名称:OpenStudio,代码行数:27,代码来源:AlgorithmRecord.cpp

示例4: compareValues

  bool InputVariableRecord_Impl::compareValues(const QSqlQuery& query) const {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    bool result = VariableRecord_Impl::compareValues(query);

    QVariant value;

    value = query.value(VariableRecordColumns::problemRecordId);
    if (value.isValid() && !value.isNull()) {
      result = result && m_problemRecordId && (*m_problemRecordId == value.toInt());
    }
    else {
      result = result && !m_problemRecordId;
    }

    value = query.value(VariableRecordColumns::uncertaintyDescriptionType);
    if (value.isValid() && !value.isNull()) {
      result = result && m_uncertaintyDescriptionType &&
               (*m_uncertaintyDescriptionType == analysis::UncertaintyDescriptionType(value.toInt()));
    }
    else {
      result = result && !m_uncertaintyDescriptionType;
    }

    value = query.value(VariableRecordColumns::inputVariableRecordType);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_inputVariableRecordType == InputVariableRecordType(value.toInt()));

    return result;
  }
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:32,代码来源:InputVariableRecord.cpp

示例5: setLastValues

void AlgorithmRecord_Impl::setLastValues(const QSqlQuery& query, ProjectDatabase& projectDatabase) {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    ObjectRecord_Impl::setLastValues(query,projectDatabase);

    QVariant value;

    value = query.value(AlgorithmRecordColumns::algorithmRecordType);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastAlgorithmRecordType = AlgorithmRecordType(value.toInt());

    value = query.value(AlgorithmRecordColumns::complete);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastComplete = value.toBool();

    value = query.value(AlgorithmRecordColumns::failed);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastFailed = value.toBool();

    value = query.value(AlgorithmRecordColumns::iter);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastIter = value.toInt();
}
开发者ID:jbl5088,项目名称:OpenStudio,代码行数:25,代码来源:AlgorithmRecord.cpp

示例6: editRecord

void ObosoblForm::editRecord()
{
    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("UPDATE obosobl SET obosoblname = :name WHERE  obosoblid = :id");
        query.bindValue(":name",editName->text());
        query.bindValue(":id",indexTemp);
        query.exec();
    }else{
        QSqlQuery query;
        query.prepare("SELECT * FROM obosobl WHERE obosoblname = :name");
        query.bindValue(":name",editName->text().simplified());
        query.exec();
        query.next();
        if(!query.isValid()){
            NumPrefix numPrefix;
            indexTemp = numPrefix.getPrefix("obosobl");
            if(indexTemp == ""){
                close();
            }
            QSqlQuery query;
            query.prepare("INSERT INTO obosobl (obosoblid, obosoblname) VALUES(:id, :name)");
            query.bindValue(":id",indexTemp);
            query.bindValue(":name",editName->text().simplified());
            query.exec();
        }else{
            QString tempString = editName->text();
            tempString += QObject::trUtf8(" is availble!");
            QMessageBox::warning(this,QObject::trUtf8("Atention!!!"),tempString);
        }
    }
    emit accept();
    close();
}
开发者ID:AndrewBatrakov,项目名称:EmployeeClient,代码行数:34,代码来源:obosoblform.cpp

示例7: DakotaAlgorithmRecordType

  DakotaAlgorithmRecord_Impl::DakotaAlgorithmRecord_Impl(const QSqlQuery& query,
                                                         ProjectDatabase& database)
    : AlgorithmRecord_Impl(query, database)
  {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    QVariant value;

    value = query.value(DakotaAlgorithmRecord::ColumnsType::dakotaAlgorithmRecordType);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_dakotaAlgorithmRecordType = DakotaAlgorithmRecordType(value.toInt());

    value = query.value(DakotaAlgorithmRecord::ColumnsType::dakotaRestartFileRecordId);
    if (value.isValid() && !value.isNull()) {
      m_dakotaRestartFileRecordId = value.toInt();
    }

    value = query.value(DakotaAlgorithmRecord::ColumnsType::dakotaOutFileRecordId);
    if (value.isValid() && !value.isNull()) {
      m_dakotaOutFileRecordId = value.toInt();
    }

    value = query.value(DakotaAlgorithmRecord::ColumnsType::jobUUID);
    if (value.isValid() && !value.isNull() && !value.toString().isEmpty()) {
      m_jobUUID = openstudio::UUID(value.toString());
    }
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:29,代码来源:DakotaAlgorithmRecord.cpp

示例8: MeasureRecordType

  MeasureRecord_Impl::MeasureRecord_Impl(const QSqlQuery& query, const ProjectDatabase& database)
    : ObjectRecord_Impl(database, query)
  {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    QVariant value;
    value = query.value(MeasureRecordColumns::measureRecordType);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_measureRecordType = MeasureRecordType(value.toInt());

    value = query.value(MeasureRecordColumns::variableRecordId);
    if (value.isValid() && !value.isNull()) {
      m_variableRecordId = value.toInt();
    }

    value = query.value(MeasureRecordColumns::isSelected);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_isSelected = value.toBool();

    value = query.value(MeasureRecordColumns::measureVectorIndex);
    if (value.isValid() && !value.isNull()) {
      m_measureVectorIndex = value.toInt();
    }
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:26,代码来源:MeasureRecord.cpp

示例9: setLastValues

void PSUADEDaceAlgorithmRecord_Impl::setLastValues(const QSqlQuery& query, ProjectDatabase& projectDatabase) {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    DakotaAlgorithmRecord_Impl::setLastValues(query,projectDatabase);
}
开发者ID:BIMDataHub,项目名称:OpenStudio-IFC-Importer,代码行数:7,代码来源:PSUADEDaceAlgorithmRecord.cpp

示例10: insert

void QxtSqlPackage::insert(QSqlQuery query)
{
    map.clear();
    record = -1;

    /*query will be invalid if next is not called first*/
    if (!query.isValid())
        query.next();

    QSqlRecord infoRecord = query.record();
    int iNumCols = infoRecord.count();
    QVector<QString> tableMap = QVector<QString>(iNumCols);

    /*first create a map of index->colname pairs*/
    for (int iLoop = 0; iLoop < iNumCols; iLoop++)
    {
        tableMap[iLoop] = infoRecord.fieldName(iLoop);
    }

    /*now use this created map to get column names
     *this should be faster than querying the QSqlRecord every time
     *but that depends on the databasetype and size of the table (number of rows and cols)
     */
    do
    {
        QHash<QString, QString> hash;
        for (int iColLoop = 0; iColLoop < iNumCols; iColLoop++)
        {
            hash[tableMap[iColLoop]] = query.value(iColLoop).toString();
        }
        map.append(hash);

    }
    while (query.next());
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:35,代码来源:qxtsqlpackage.cpp

示例11: compareValues

  bool SamplingAlgorithmRecord_Impl::compareValues(const QSqlQuery& query) const {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    bool result = DakotaAlgorithmRecord_Impl::compareValues(query);

    QVariant value;

    value = query.value(SamplingAlgorithmRecord::ColumnsType::samplingAlgorithmSampleType);
    if (value.isValid() && !value.isNull()) {
      result = result && m_sampleType && (*m_sampleType == analysis::SamplingAlgorithmSampleType(value.toInt()));
    }
    else {
      result = result && !m_sampleType;
    }

    value = query.value(SamplingAlgorithmRecord::ColumnsType::samplingAlgorithmRNGType);
    if (value.isValid() && !value.isNull()) {
      result = result && m_rngType && (*m_rngType == analysis::SamplingAlgorithmRNGType(value.toInt()));
    }
    else {
      result = result && !m_rngType;
    }

    return result;
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:27,代码来源:SamplingAlgorithmRecord.cpp

示例12: setLastValues

  void SamplingAlgorithmRecord_Impl::setLastValues(const QSqlQuery& query,
                          ProjectDatabase& projectDatabase) {
    OS_ASSERT(query.isValid());
    OS_ASSERT(query.isActive());
    OS_ASSERT(query.isSelect());

    DakotaAlgorithmRecord_Impl::setLastValues(query,projectDatabase);

    QVariant value;

    value = query.value(SamplingAlgorithmRecord::ColumnsType::samplingAlgorithmSampleType);
    if (value.isValid() && !value.isNull()) {
      m_lastSampleType = analysis::SamplingAlgorithmSampleType(value.toInt());
    }
    else {
      m_lastSampleType.reset();
    }

    value = query.value(SamplingAlgorithmRecord::ColumnsType::samplingAlgorithmRNGType);
    if (value.isValid() && !value.isNull()) {
      m_lastRNGType = analysis::SamplingAlgorithmRNGType(value.toInt());
    }
    else {
      m_lastRNGType.reset();
    }
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:26,代码来源:SamplingAlgorithmRecord.cpp

示例13: getPath

QString Prefix::getPath(const QString prefix_name) const{
    QString value;

    if (prefix_name == "Default"){
        value = QDir::homePath();
        value.append("/.wine");
        return value;
    }

    QSqlQuery query;

    query.prepare("SELECT path FROM prefix WHERE name=:prefix_name");
    query.bindValue(":prefix_name", prefix_name);

    if (query.exec()){
        query.first();
        if (query.isValid()){
            if (query.value(0).toString().isEmpty()){
                value = QDir::homePath();
                value.append("/.wine");
            } else {
                value.append(query.value(0).toString());
            }
        }
    } else {
        qDebug()<<"SqlError: "<<query.lastError();
    }
    query.clear();
    return value;
}
开发者ID:Vdragon,项目名称:q4wine,代码行数:30,代码来源:prefix.cpp

示例14: getQRZEntityName

QString World::getQRZEntityName(const QString _qrz)
{
 //   qDebug() << "World::getQRZEntityName: " << _qrz << endl;

    QSqlQuery query;
    int prefixIDNumber = getPrefixId(_qrz);

    queryString = "SELECT dxcc FROM prefixesofentity WHERE id=='" + QString::number(prefixIDNumber) +"'";
    //qDebug() << "World::getQRZEntityName: queryString-1: " << queryString << endl;
    query.exec(queryString);
    query.next();
    prefixIDNumber = (query.value(0)).toInt();
    //qDebug() << "World::getQRZEntityName: " <<_qrz << " = " <<  (query.value(0)).toString() << endl;

    queryString = "SELECT name FROM entity WHERE id=='" + QString::number(prefixIDNumber) +"'";
    //qDebug() << "World::getQRZEntityName: queryString-2: " << queryString << endl;
    query.exec(queryString);
    query.next();
    //qDebug() << "World::getQRZEntityName end: " << _qrz << " = " << (query.value(0)).toString() << endl;

    if (query.isValid()){
        return (query.value(0)).toString();
    }else{
        return "";
    }

    return "";
}
开发者ID:BackupTheBerlios,项目名称:kontest-svn,代码行数:28,代码来源:world.cpp

示例15: version

QString toQSqlConnectionSub::version()
{
    QString ret;
    try
    {
        LockingPtr<QSqlDatabase> ptr(Connection, Lock);

        QSqlQuery query = ptr->exec(toSQL::sql("toQSqlConnection:Version", ParentConnection));
        if (query.next())
        {
            if (query.isValid())
            {
                QSqlRecord record = query.record();
                QVariant val = query.value(record.count() - 1);
                ret = val.toString().toLatin1();
            }
        }
    }
    catch (std::exception const&e)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception:" << e.what() << std::endl;
        throw e;
    }
    catch (QString const&s)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception:" << s << std::endl;
        throw s;
    }
    catch (...)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
        throw;
    }
    return ret;
}
开发者ID:tora-tool,项目名称:tora,代码行数:35,代码来源:toqsqlconnection.cpp


注:本文中的QSqlQuery::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。