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


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

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


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

示例1: loadRefList

// englisch ??????????????????? !!!!!!!!!!!!!!!!!!!!!!!!
// ---------------------------------------------------------------------------
// ReferenzListe mit Spalten_Namen, UserFeldNamen und ADIf_referenzNamen laden
// ( 4_dimensionales Arryfeld ) zur Aufnahme des Datensatzes
// ---------------------------------------------------------------------------
void wadif::loadRefList()
{
    QSqlQuery query;
    qy = "SELECT dbfield,refnam,adifnam FROM refnamen WHERE type = '2' ORDER BY idn";
    query.exec(qy);
    openRefListQso(query.size());
    
    i = 0;
    while(query.next()) {                                   // Datensatz erzeugen
       n = 0;                                                        // Index_Felder
       adh[i].pos = i;                                               // index_Nr
       strcpy(adh[i].field,query.value(n++).toString().toAscii());   // dbSpalten_Namen
       strcpy(adh[i].refnam,query.value(n++).toString().toAscii());  // User_Name
       strcpy(adh[i].adifnam,query.value(n++).toString().toAscii()); // ADIF_Name
       strcpy(adh[i].value,"");                            // Datensatz_Feld_variable
       i++;
    }
    
 // englich ????????????? !!!!!!!!!!!!!!!!!!!
     // funqsl Tabelle
    qy = "SELECT dbfield,refnam,adifnam FROM refnamen WHERE type='3' OR type ='4' ORDER BY idn";
    query.exec(qy);
    openRefListQsl(query.size());
    i = 0;
    while(query.next()) {                                    // Datensatz erzeugen
       n = 0;                                                         // Index_Felder
       adhq[i].pos = i;                                               // index_Nr
       strcpy(adhq[i].field,query.value(n++).toString().toAscii());   // dbSpalten_Namen
       strcpy(adhq[i].refnam,query.value(n++).toString().toAscii());  // User_Name
       strcpy(adhq[i].adifnam,query.value(n++).toString().toAscii()); // ADIF_Name
       strcpy(adhq[i].value,"");                             // Datensatz_Feld_variable
       i++;
    }
}
开发者ID:frohro,项目名称:qtlog,代码行数:39,代码来源:wadif.cpp

示例2: LoadLocalAccount

/**
 * @paragraph This method loads an account saved in the local database
 * @brief ServerPanel::LoadLocalAccount
 * @param SpLocalAccount slaAccount
 * @return bool
 */
bool ServerPanel::LoadLocalAccount(SpLocalAccount slaAccount) {
    // Check for a username and password
    if (!slaAccount.getProperty("sUsername").toString().isEmpty() && !slaAccount.getProperty("sPassword").toString().isEmpty()) {
        // Grab the QSqlQuery object
        QSqlQuery qsqLocalAccount = slaAccount.toQuery(this->mDbc, this->mConfig->value("sqlQueries/selectLocalAccountByUsernameAndPassword").toString());
        // Try to execute the query
        if (!qsqLocalAccount.exec()) {
            // Dispatch a message
            this->DispatchMessageBox(qsqLocalAccount.lastError().text(), Error);
            // We're done
            return false;
        }
        // Check for results
        if (!qsqLocalAccount.size()) {
            // We're done
            return false;
        }
        // Loop through the results
        while (qsqLocalAccount.next()) {
            // Set the account object
            slaAccount = SpLocalAccount(qsqLocalAccount.record());
        }
        // Set the account into the system
        this->mCurrentAccount = slaAccount;
        // We're done
        return true;
    }
    // Check for a server address
    if (!slaAccount.getProperty("sAddress").toString().isEmpty()) {
        // Grab the QSqlQuery object
        QSqlQuery qsqAccount = slaAccount.toQuery(this->mDbc, this->mConfig->value("sqlQueries/selectLocalServerAccount").toString());
        // Try to execute the query
        if (!qsqAccount.exec()) {
            // Dispatch a message
            this->DispatchMessageBox(qsqAccount.lastError().text(), Error);
            // We're done
            return false;
        }
        // Check for results
        if (!qsqAccount.size()) {
            // We're done
            return false;
        }
        // Loop through the results
        while (qsqAccount.next()) {
            // Populate the structure
            slaAccount = SpLocalAccount(qsqAccount.record());
        }
        // Set the current account
        this->mCurrentAccount = slaAccount;
        // We're done
        return true;
    }
    // Dispatch a message
    this->DispatchMessageBox("No account identifier found.", Error);
    // We're done
    return false;
}
开发者ID:bolvarak,项目名称:ServerPanel,代码行数:64,代码来源:ServerPanel.cpp

示例3: LoadLocalServer

/**
 * @paragraph This method loads a saved server from the local database
 * @brief ServerPanel::LoadLocalServer
 * @param SpLocalServer slsServer
 * @return bool
 */
bool ServerPanel::LoadLocalServer(SpLocalServer slsServer) {
    // Are we loading by id
    if (slsServer.getProperty("iServerId").toInt() > 0) {
        // Grab the QSqlQuery object
        QSqlQuery qsqLocalServer = slsServer.toQuery(this->mDbc, this->mConfig->value("sqlQueries/selectLocalServerByServerId").toString());
        // Try to execute the query
        if (!qsqLocalServer.exec()) {
            // Dispatch a message
            this->DispatchMessageBox(qsqLocalServer.lastError().text(), Error);
            // We're done
            return false;
        }
        // Check for results
        if (!qsqLocalServer.size()) {
            // We're done
            return false;
        }
        // Loop through the results
        while (qsqLocalServer.next()) {
            // Set the server object
            slsServer = SpLocalServer(qsqLocalServer.record());
        }
        // Set the server into the system
        this->mCurrentServer = slsServer;
        // We're done
        return true;
    }
    // Are we loading by server address
    if (!slsServer.getProperty("sAddress").toString().isEmpty()) {
        // Grab the QSqlQuery object
        QSqlQuery qsqLocalServer = slsServer.toQuery(this->mDbc, this->mConfig->value("sqlQueries/selectLocalServerByServerAddress").toString());
        // Try to execute the query
        if (!qsqLocalServer.exec()) {
            // We're done
            return false;
        }
        // Check for results
        if (!qsqLocalServer.size()) {
            // We're done
            return false;
        }
        // Loop through the results
        while (qsqLocalServer.next()) {
            // Populate the structure
            slsServer = SpLocalServer(qsqLocalServer.record());
        }
        // Set the server into the system
        this->mCurrentServer = slsServer;
        // We're done
        return true;
    }
    // Dispatch a message
    this->DispatchMessageBox("No server identifier was found.  Please check for a valid server ID or server address and try again.", Error);
    // We're done
    return false;
}
开发者ID:bolvarak,项目名称:ServerPanel,代码行数:62,代码来源:ServerPanel.cpp

示例4:

/* SQL without C++:
SELECT id, last, first, full_name, active
FROM prescribers
WHERE active = 1
ORDER BY last, first;

SELECT id, last, first, initials, active
FROM pharmacists
WHERE active = 1
ORDER BY last, first;
*/
bool Prescription_01::initCustom()
{
	QSqlQuery model;				// Contains the query
	AlertInterface alert;
	PrescriberRecord *presTemp;
	PharmacistRecord *pharmTemp;
	int i;							// Increment var

	model.prepare("SELECT id, last, first, full_name, active "
				  "FROM prescribers "
				  "WHERE active = 1 "
				  "ORDER BY last, first;");

	if (!alert.attemptQuery(&model)) {
		return false;
	}
	for (i = 0; i < model.size(); i++) {
		model.next();
		presTemp = new PrescriberRecord;
		presTemp->setId(model.value(0).toInt());
		presTemp->setLast(model.value(1).toString());
		presTemp->setFirst(model.value(2).toString());
		presTemp->setFull_name(model.value(3).toString());
		presTemp->setActive(model.value(4).toBool());
		prescribers.append(presTemp);
	}

	model.prepare("SELECT id, last, first, initials, active "
				  "FROM pharmacists "
				  "WHERE active = 1 "
				  "ORDER BY last, first;");

	if (!alert.attemptQuery(&model)) {
		deleteLists();
		return false;
	}
	for (i = 0; i < model.size(); i++) {
		model.next();
		pharmTemp = new PharmacistRecord;
		pharmTemp->setId(model.value(0).toInt());
		pharmTemp->setLast(model.value(1).toString());
		pharmTemp->setFirst(model.value(2).toString());
		pharmTemp->setInitials(model.value(3).toString());
		pharmTemp->setActive(model.value(4).toBool());
		pharmacists.append(pharmTemp);
	}

	setupComboBoxes();

	return true;
}
开发者ID:kyledevans,项目名称:Medicine-Track,代码行数:62,代码来源:prescription_01.cpp

示例5: fillSensorRelated

int MainWindow::fillSensorRelated()
{
    QString seqQuery;
    QSqlQuery query;

    seqQuery  = "select distinct name from ActionRules where ruleActionText like '%";
    seqQuery += "::" + ui->sensorComboBox->currentText().section("::",0,0) + "::%' and experimentalLocationId =" + experimentLocation + " order by name";

    qDebug()<<seqQuery;

    query = seqQuery;

    qDebug()<<seqQuery;

    ui->sensorListWidget->clear();

    query.exec();

    while(query.next())
   {
      ui->sensorListWidget->addItem(query.value(0).toString());
    }

    return query.size();


}
开发者ID:uh-adapsys,项目名称:accompany,代码行数:27,代码来源:mainwindow.cpp

示例6: find

int Category::find()
{
//  qDebug() << "find category";
  QString query = QString("SELECT id, priceID FROM categories WHERE "
                          "teamID = %1 AND techID = %2 AND typeID = %3 AND homeID = %4 AND line = %5;")
      .arg(teamID).arg(techID).arg(typeID).arg(homeID).arg(line);

//  qDebug() << query;

  QSqlQuery *q = new QSqlQuery(query, App::theApp()->db());

  q->exec();

  if (q->size() == 0) { // нет этой категории, создаем категорию...
    if (!create()) return -1;
    // Создали, находим (рекурсивно)
    return find();
  }

  q->first();

  int id = q->value("id").toInt();
  int priceID = q->value("priceID").toInt();

  price = Price(priceID);
//  qDebug() << "find category. ID = " << id << " priceID = " << priceID;
  return id;
}
开发者ID:nektuty,项目名称:orders,代码行数:28,代码来源:other.cpp

示例7: Patient

Patient *SearchPatient(QString id)
{
    if(id=="")
        return NULL;
    QSqlQuery query;
    QString sql="select * from TPatient where Id='"+id+"'";
    bool boo=query.exec(sql);
    if(!boo || query.size()==0)
        return NULL;
    query.first();
    Patient *p=new Patient();
    p->setNom(query.value(1).toString());
    p->setPrenom(query.value(2).toString());
    p->setAdresse(query.value(3).toString());
    p->setVille(query.value(4).toString());
    p->setCP(query.value(5).toInt());
    p->setCommentaire(query.value(6).toString());
    p->setTelephone(query.value(7).toString());
    p->setDateDebut(query.value(8).toDate());
    p->setDuree(query.value(9).toInt());
    p->setPriorite(query.value(10).toInt());

    query.exec("select IdRessource from TConsult where IdPatient="+id);
    while(query.next())
    {
        p->vIdRessource.push_back(query.value(0).toInt());
    }
    return p;
}
开发者ID:pholien,项目名称:QtProjet,代码行数:29,代码来源:Controleur_patient.cpp

示例8: userLogin

bool Auth::userLogin ( const QString &username , const QString &password )
{
    if ( m_AuthType == NONE && !m_needAuth )
    {
        qDebug ( "userLogin::Try to login with NONE ? Please Fix this." );
        return m_isAuth = true;
    }
    /*if ( m_AuthType == HASHED){
            qDebug("userLogin::HASHED Auth not implemented yet!");
            return m_isAuth = true;
    }*/
    QSqlDatabase db = QSqlDatabase::database ( m_db );

    QSqlQuery query = db.exec ( QString ( "SELECT * from Users where Username = '%1' and Password = password('%2') and Enabled = 1" ).arg ( username ).arg ( password ) );
    query.next();
    if ( query.size() != 1 )
        return m_isAuth = false;

    /* OK */
    m_userName = username;
    if ( m_AuthType == HASHED ){
	  int passField = query.record().indexOf("Password");
	  m_hashPassword = query.value( passField ).toString();
    }
    
    m_password = password;
    saveSettings();
    return m_isAuth = true;
}
开发者ID:Sheridan,项目名称:ZoneMinder-Viewer,代码行数:29,代码来源:auth.cpp

示例9: qDebug

census * DatabaseHandler::getCensusData(QString objId) {
    qDebug() << "Getting object specific query for ID: " << objId;
    QString qstr = "SELECT tp, name, confidence, beh, age, gen, dir, rem, censor, imgqual FROM census WHERE rcns_id=" + objId +
            " AND usr!='" + config->user() + "' AND censor=1";
    qDebug() << qstr;
    // if there is already an entry in census db-table,
    // initialize census structure with these values
    QSqlQuery * query = new QSqlQuery(qstr);
    if (query->size() != 1) {
        delete query;
        return 0;
    }
    census * obj = new census;
    if (query->next()) {
        obj->type = query->value(0).toString();
        obj->name = query->value(1).toString();
        obj->confidence = query->value(2).toInt();
        obj->behavior = query->value(3).toString();
        obj->age = query->value(4).toString();
        obj->gender = query->value(5).toString();
        obj->direction = query->value(6).toInt();
        obj->remarks = query->value(7).toString();
        obj->censor = query->value(8).toInt();
        obj->imageQuality = query->value(9).toInt();
    }
    delete query;
    return obj;
}
开发者ID:ifaoe,项目名称:2014-10-Bird-View,代码行数:28,代码来源:DatabaseHandler.cpp

示例10: showError

void FrmCell::filterModel4Combo()
{
    QString strQuery =
            "select     fr_gls2als.id_abstract_landingsite as ls, ref_minor_strata.id_gls, fr_gls2als.id_gls as expr1"
            " from         ref_minor_strata inner join"
            "                      fr_time on ref_minor_strata.id_frame_time = fr_time.id inner join"
            "                      fr_frame on fr_time.id_frame = fr_frame.id inner join"
            "                      fr_sub_frame on fr_frame.id = fr_sub_frame.id_frame inner join"
            "                      fr_gls2als on fr_sub_frame.id = fr_gls2als.id_sub_frame and ref_minor_strata.id_gls = fr_gls2als.id_gls"
            " where     (ref_minor_strata.id = :id)"
;

    QSqlQuery query;
    query.prepare(strQuery);
    query.bindValue(0,m_sample->minorStrataId);
    if (!query.exec()){
        emit showError(tr("Could not obtain filter for Landing Sites!"));
        return;
    }

    Q_ASSERT_X(query.size()>=1, "Cell", QString(QString("Selection of a GLS without landing sites!") + m_sample->print()).toUtf8().constData());

    QString strFilter("");
     while (query.next()) {
        strFilter.append("ID=" + query.value(0).toString());
        strFilter.append(" OR ");
     }
     if (!strFilter.isEmpty())
         strFilter=strFilter.remove(strFilter.size()-QString(" OR ").length(),QString(" OR ").length());

    tSampCell->relationModel(2)->setFilter(strFilter);
    //first we set the relation; then we create a mapper and assign the (amended) model to the mapper;
    initMapper1();
}
开发者ID:doublebyte1,项目名称:faocas_qc,代码行数:34,代码来源:frmcell.cpp

示例11: testAddAnalysis

void TestAnalysisDao::testAddAnalysis(){
    //Add network and archive
    addTestArchive1();

    //Create analysis info with analysis information
    AnalysisInfo analysisInfo(0, testNetID, testArchive1ID, QDateTime::fromTime_t(1234321), "Test analysis description 1", QHash<QString, double>(), 1);

    try{
		//Invoke method that is being tested
		AnalysisDao analysisDao(analysisDBInfo);
		analysisDao.addAnalysis(analysisInfo);

		//Check that analysis has been added
		QSqlQuery query = getAnalysisQuery("SELECT NetworkID, ArchiveID, StartTime, Description, AnalysisTypeID FROM Analyses");
		executeQuery(query);

		//Should only be one row
		QCOMPARE(query.size(), 1);
		query.next();

		//Check details of archive
		QVERIFY( analysisInfo.getID() != 0);
		QCOMPARE(query.value(0).toUInt(), testNetID);
		QCOMPARE(query.value(1).toUInt(), testArchive1ID);
		QCOMPARE(query.value(2).toUInt(), (unsigned int)1234321);
		QCOMPARE(query.value(3).toString(), QString("Test analysis description 1"));
		QCOMPARE(query.value(4).toUInt(), (unsigned int)1);
    }
    catch(SpikeStreamException& ex){
		QFAIL(ex.getMessage().toAscii());
    }

}
开发者ID:nico202,项目名称:spikestream,代码行数:33,代码来源:TestAnalysisDao.cpp

示例12: completar

bool otros::completar()
{
    QSqlQuery query;
    query.prepare("SELECT p.idProducto,p.accesorios,p.observaciones FROM Producto p,Otros o WHERE p.idProducto=o.Producto_idProducto AND p.codigo=? AND p.descripcion=? AND p.precioCompra=? AND p.precioVenta=? AND p.precioDescuento=? AND p.stock=? AND p.Estado_idEstado=? AND p.Marca_idMarca=? AND o.Color_idColor=? AND o.Talla_idTalla=? AND o.Calidad_idCalidad=? AND o.TipoOtros_idTipoOtros=? AND o.Genero_idGenero=?");//falta seleccionar colaborador
    query.bindValue(0,codigo);
    query.bindValue(1,descripcion);
    query.bindValue(2,precioCompra);
    query.bindValue(3,precioVenta);
    query.bindValue(4,precioDescuento);
    query.bindValue(5,stock);
    query.bindValue(6,pEstado.getIdEstado());
    query.bindValue(7,pMarca.getIdMarca());
    query.bindValue(8,pColor.getIdColor());
    query.bindValue(9,pTalla.getIdTalla());
    query.bindValue(10,pCalidad.getIdCalidad());
    query.bindValue(11,pTipoOtros.getIdTipoOtros());
    query.bindValue(12,pGenero.getIdgenero());
    if(query.exec())
    {
        if(query.size()!=0)
        {
            query.first();
            idProducto=query.value(0).toString();
            accesorios=query.value(1).toString();
            observaciones=query.value(2).toString();
            return true;
        }
        else
            return false;
    }
    else
        return false;
}
开发者ID:rodety,项目名称:manager,代码行数:33,代码来源:otros.cpp

示例13: makeQueryResultString

QString DatabaseController::makeQueryResultString(const QSqlQuery& query, int iNbRowsSelected)
{
	QString szResultString;
	QTime time;

	int iNbRow = 0;
	if(query.isSelect()){
		iNbRow = query.size();
		if(iNbRow == -1){
			iNbRow = iNbRowsSelected;
		}
	} else {
		iNbRow = query.numRowsAffected();
	}

	// Write the time
	szResultString += time.currentTime().toString()+" => ";
	// Write sql error
	if(query.lastError().isValid()){
		szResultString += "Query executed with error(s) (" + query.lastError().text() + "): \n";
	}else{
		szResultString += "Query executed successfully: ";
	}
	// Write number of rows
	szResultString += QString::number(iNbRow)+" row(s) selected/affected\n";
	// Write query
	if(!query.lastQuery().isEmpty()){
		szResultString += query.lastQuery() + "\n";
	}
	szResultString += "\n";

	return szResultString;
}
开发者ID:Jet1oeil,项目名称:opendbviewer,代码行数:33,代码来源:DatabaseController.cpp

示例14: makeQuery

QSqlQuery MainData::makeQuery(QString q_str,bool& made,bool silent)
{
    QSqlQuery query;
    try
    {
        query.exec(q_str);
        if(query.isActive())
        {

             if(query.size()==0) throw "Неверный логин/пароль";
             if(!query.first()) throw "Ошибка при запросе данных из БД";
             made=true;
             return query;
        }
        else
            throw "Не могу выполнить запрос к БД";
    }
    catch(QString message)
    {

        if(!silent) MessageHandler::showMessage(MessageHandler::Error,message,0);
        made=false;
        query.clear();
    }
    catch(...)
    {
        if(!silent) MessageHandler::showMessage(MessageHandler::Error,"Ошибка при работе с БД\n"+q_str,0);
        made=false;
        query.clear();
    }


 }
开发者ID:alexeydonald,项目名称:Base,代码行数:33,代码来源:MainData.cpp

示例15: NewAwdValues

// ---------------------------------------------
// Neuen AWARD_Type anlegen
// ---------------------------------------------
void confMode::NewAwdValues()
{
      QSqlQuery query;
      if(NameTypeLineEdit->text().count() == 0) {
        QMessageBox::information( this,
        tr("INFO"),
        tr("\n\nKeinen leeren AWD Type !"),
        QMessageBox::Ok);
        return;
      }
      
      qy = "SELECT aset FROM wawdlist WHERE atype='"+NameTypeLineEdit->text()+"'";
      query.exec(qy);
      if(query.size() != 0) {                                         // schon vorhanden   
           QMessageBox::information(this,
           tr("Information"),
           tr("\n\nAWD Type ist schon vorhanden"),
           QMessageBox::Ok);
          return;
      }
      if(AwdSetLineEdit->text().count() == 0)
         AwdSetLineEdit->setText("0");
      qy = "INSERT INTO wawdlist VALUES(0,'"+AwdSetLineEdit->text();  // aset : sortNo
      qy += "','"+NameTypeLineEdit->text();                           // atype : Name_Award-Type
      qy += "','APP_QTLOG_"+NameTypeLineEdit->text()+"')";            // Applocation_QtLog + Name-AWtype
      query.exec(qy);
         
      QTreeWidgetItem *item = new QTreeWidgetItem(awdList);
      item->setText(0,AwdSetLineEdit->text());                        // aset
      item->setText(1, NameTypeLineEdit->text());                     // atype
      NewPushButton->hide();
}
开发者ID:frohro,项目名称:qtlog,代码行数:35,代码来源:confMode.cpp


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