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


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

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


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

示例1: countOnlineUsers

void Buddies::countOnlineUsers()
{

	QSqlQuery query;


	query.exec("select count(*) from b_main where b_status='Online'");

	if (!query.isActive())
	    QMessageBox::warning(this, tr("Database Error"),
	                         query.lastError().text());
	while (query.next()) {
	QString Penguins = query.value(0).toString();

	qDebug("=> Online users");

	ui.statusbar->showMessage(tr("Currently "+Penguins+" Buddies online"), 2000);

	}

}
开发者ID:ioannisb,项目名称:Buddies-1.10,代码行数:21,代码来源:buddies.cpp

示例2: createTablesOfTheRegisters

void DataBase::createTablesOfTheRegisters(QList<FRegister *> &registers)
{
    QSqlQuery query;
    QString queryString = "";
    for(int i=0; i<registers.size(); i++){
        queryString = "create table _InfoReg" + registers[i]->attributes().value("name").toString() + " (reference text, ";
        QMapIterator<QString, QVariant> iter(registers[i]->attributes());
        while(iter.hasNext()){
            iter.next();
            queryString += iter.key() +" text, ";
        }
        queryString.remove(queryString.size() - 2, 2);
        queryString += ")";
        query.exec(queryString);
        qDebug()<<queryString;
        if(!query.isActive()){
            qDebug()<<query.lastError();
        }
        queryString = "";
    }
}
开发者ID:DimaRomanyuk,项目名称:QEF,代码行数:21,代码来源:database.cpp

示例3: slotDeleteLine

//=============================================================================
// SLOT: Delete the line with the given ID.
//=============================================================================
void CAddress::slotDeleteLine (QString id)
{
  //----------------------------------------------------------------------------
  // If ID is an empty string, the line was not saved already, so nothing has
  // to bo done.
  //----------------------------------------------------------------------------
  if (id != "")
  {
    QSqlQuery query ("DELETE FROM contacts_addresses WHERE address_id = " + id);

    if (!query.isActive())
    {
      SHOW_DB_ERROR(tr ("Error during deleting the data"), query);
      return;
    }

    mDB->commit();
  }
  
  loadData (mCurrent, mReadonly);
}
开发者ID:BackupTheBerlios,项目名称:enixs,代码行数:24,代码来源:address.cpp

示例4: createTablesOfTheCatalogs

void DataBase::createTablesOfTheCatalogs(QList<FCatalog *> &catalogs)
{
    QSqlQuery query;
    QString queryString = "";
    for(int i=0; i<catalogs.size(); i++){
        queryString = "create table _Reference" + catalogs[i]->attributes().value("name").toString() + " (reference text, parent text, master text, mark_removal text, predefined text, ";
        QMapIterator<QString, QVariant> iter(catalogs[i]->attributes());
        while(iter.hasNext()){
            iter.next();
            queryString += iter.key() +" text, ";
        }
        queryString.remove(queryString.size() - 2, 2);
        queryString += ")";
        query.exec(queryString);
        qDebug()<<queryString;
        if(!query.isActive()){
            qDebug()<<query.lastError();
        }
        queryString = "";
    }
}
开发者ID:DimaRomanyuk,项目名称:QEF,代码行数:21,代码来源:database.cpp

示例5: isExist

bool CatalogClass::isExist(QString _catalogName)
{
	QSqlQuery *q = NULL;
	bool result = false;
	q = new QSqlQuery(db);
	if (!q)
		return result;
	QString sql = "SELECT id, name FROM Catalogs Where name='%1'";
	sql = sql.arg(_catalogName);
            
	q->exec(sql);
	if (q->isActive())
	{
		q->first();
/*        if (q->isValid())
		printQS(QString("Catalog with name %1 exists").arg(_catalogName));*/
		result = q->isValid();
	}
	delete q;
	return result;
}
开发者ID:emware,项目名称:qtcat-emware,代码行数:21,代码来源:catalogclass.cpp

示例6: createTablesOfTheDocuments

void DataBase::createTablesOfTheDocuments(QList<FDocument *>& documents)
{
    QSqlQuery query;
    QString queryString = "";
    for(int i=0; i<documents.size(); i++){
        queryString = "create table _Document" + documents[i]->attributes().value("name").toString() + " (reference text, mark_removal text, is_post text, ";
        QMapIterator<QString, QVariant> iter(documents[i]->attributes());
        while(iter.hasNext()){
            iter.next();
            queryString += iter.key() +" text, ";
        }
        queryString.remove(queryString.size() - 2, 2);
        queryString += ")";
        query.exec(queryString);
        qDebug()<<queryString;
        if(!query.isActive()){
            qDebug()<<query.lastError();
        }
        queryString = "";
    }
}
开发者ID:DimaRomanyuk,项目名称:QEF,代码行数:21,代码来源:database.cpp

示例7: insertMessage

bool Database::insertMessage(QVariantMap message)
{
    QSqlQuery query;
    query.prepare(
            "INSERT INTO messagesTab (id,date,fromId,toId,fwdDate,fwdFromId,message,read,mediaType,attachmentId) "
                    "VALUES (?,?,?,?,?,?,?,?,?,?)");
    query.bindValue(0, message.value("id"));
    query.bindValue(1, message.value("date"));
    query.bindValue(2, message.value("fromId"));
    query.bindValue(3, message.value("toId"));
    query.bindValue(4, message.value("fwDate"));
    query.bindValue(5, message.value("fwdFromId"));
    query.bindValue(6, message.value("message"));
    query.bindValue(7, message.value("read"));
    query.bindValue(8, message.value("type"));
    query.bindValue(9, message.value("attachmentId"));
    query.exec();
    if (query.isActive())
        return true;
    return false;
}
开发者ID:Ahamtech,项目名称:TB10,代码行数:21,代码来源:database.cpp

示例8: setLastValues

  void UrlRecord_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(UrlRecord::ColumnsType::parentDatabaseTableName);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastParentDatabaseTableName = value.toString().toStdString();

    value = query.value(UrlRecord::ColumnsType::parentRecordId);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastParentRecordId = value.toInt();

    value = query.value(UrlRecord::ColumnsType::url);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastUrl = openstudio::Url(value.toString());
  }
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:21,代码来源:UrlRecord.cpp

示例9: createNewExcelDatabase

void DbManager::createNewExcelDatabase(const QString& path)
{
    QXlsx::Document sns_new(path);

    QSqlQuery query;
    QString query_string =
            "SELECT                 people.id, "
                                   "people.first_name, "
                                   "people.last_name, "
                                   "people.personal_code, "
                                   "people.job, "
                                   "people.email, "
                                   "people.phone, "
                                   "address.street_name, "
                                   "address.municipality, "
                                   "address.zip, "
                                   "address.province, "
                                   "address.state, "
                                   "license.license_name "
            "FROM people "
            "INNER JOIN address ON people.id = address.person "
            "INNER JOIN people_license ON people_license.id_person = people.id "
            "INNER JOIN license ON   license.id = people_license.id_license ";

    query.prepare(query_string);
    if(query.exec()) {
        if(query.isActive()) {
            if(query.first()) {
                int row = 3;
                while(query.next()) {
                    for(int i = 1; i < 14; i++) {
                        sns_new.write(row, i , query.value(i - 1));
                    }
                    ++row;
                }
            }
        }
    }
    sns_new.save();
}
开发者ID:sgranfius,项目名称:sns,代码行数:40,代码来源:dbmanager.cpp

示例10:

QQueue<CustomerSite> ControlThread::buildCustomerList()
{
	QQueue<CustomerSite>  newCustomerSiteQueue;
	QSqlQuery customersitequery;
	customersitequery.prepare("SELECT customer_sites.* FROM customer_sites INNER JOIN users ON customer_sites.user=users.id WHERE customer_sites.site=? AND active=1");
	customersitequery.addBindValue(site_id);
	customersitequery.exec();
	if(customersitequery.isActive())
	{
		while(customersitequery.next()) {
			CustomerSite site;
			site.setId(customersitequery.record().value("id").toULongLong());
			site.setUserId(customersitequery.record().value("user").toULongLong());
			site.setRepeatTime(customersitequery.record().value("repeat_time").toUInt());
			site.setLogSuccessful(customersitequery.record().value("log_successful").toBool());
			site.setFullPage(customersitequery.record().value("full_page").toBool());
			site.setName(customersitequery.record().value("name").toString());
			site.setUrl(customersitequery.record().value("url").toString());
			site.setMaxTimeOut(customersitequery.record().value("max_timeout").toUInt());
			if(customersitequery.record().value("host").toString() != "")
			{
				site.setHost(customersitequery.record().value("host").toString());
			}
			else
			{
				site.setHost(QUrl(site.getUrl()).host());
			}
				
			site.setFetchRemote(customersitequery.record().value("fetch_remote").toBool());
			site.setMonitorSiteId(site_id);
			
			newCustomerSiteQueue.enqueue(site);
		}
	}
	else {
// 		qDebug() << "ControlThread::BuildSiteList - Query Failed" << customersitequery.lastError().text();
	}
	
	return newCustomerSiteQueue;
}
开发者ID:tebruno99,项目名称:pstats,代码行数:40,代码来源:controlthread.cpp

示例11: compareValues

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

    bool result = CloudSessionRecord_Impl::compareValues(query);

    QVariant value;

    value = query.value(AWSSessionRecord::ColumnsType::numServerProcessors);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_numServerProcessors == value.toUInt());

    value = query.value(AWSSessionRecord::ColumnsType::numWorkerProcessors);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_numWorkerProcessors == value.toUInt());

    value = query.value(AWSSessionRecord::ColumnsType::privateKey);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_privateKey == value.toString().toStdString());

    value = query.value(AWSSessionRecord::ColumnsType::timestamp);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_timestamp == value.toString().toStdString());

    value = query.value(AWSSessionRecord::ColumnsType::region);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_region == value.toString().toStdString());

    value = query.value(AWSSessionRecord::ColumnsType::serverInstanceType);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_serverInstanceType == value.toString().toStdString());

    value = query.value(AWSSessionRecord::ColumnsType::workerInstanceType);
    OS_ASSERT(value.isValid() && !value.isNull());
    result = result && (m_workerInstanceType == value.toString().toStdString());

    return result;
}
开发者ID:whztt07,项目名称:OpenStudio,代码行数:39,代码来源:AWSSessionRecord.cpp

示例12: deleteRecordOfTablePost

void SizPostForm::deleteRecordOfTablePost()
{
    QTextStream stream(&exchangeFile);
    QString line;
    while(!stream.atEnd()){
        stream.readLine();
    }

    int k = QMessageBox::question(this,trUtf8("Attention!!"),
                              trUtf8("Really delete?"),
                                  QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
    if(k == QMessageBox::Yes){
        QSqlQuery query;
        query.prepare("DELETE FROM postsizlist WHERE (postid = :postid AND postsizid = :postsizid)");
        query.bindValue(":postsizid",indexTemp);
        QSqlQuery queryID;
        queryID.prepare("SELECT postid FROM post WHERE postname = :postname");
        queryID.bindValue(":postname",postView->item(postView->currentRow(),2)->text());
        queryID.exec();
        queryID.next();
        query.bindValue(":postid",queryID.value(0).toString());
        query.exec();

        if(!query.isActive()){
            QMessageBox::warning(this,QObject::trUtf8("Post Siz Table, DELETE ERROR!"),
                                 query.lastError().text());
            return;
        }
        line += "DELETE FROM postsizlist WHERE (postid = '";
        line += queryID.value(0).toString().toUtf8();
        line += "' AND postsizid = '";
        line += indexTemp.toUtf8();
        line += "')";
        line += "\r\n";
        stream<<line;
        postView->removeRow(postView->currentRow());
        postView->repaint();
    }
}
开发者ID:AndrewBatrakov,项目名称:EmployeeClient,代码行数:39,代码来源:sizpostform.cpp

示例13: record

QSqlRecord QMYSQLDriver::record( const QSqlQuery& query ) const
{
    QSqlRecord fil;
    if ( !isOpen() )
	return fil;
    if ( query.isActive() && query.isSelect() && query.driver() == this ) {
	QMYSQLResult* result =  (QMYSQLResult*)query.result();
	QMYSQLResultPrivate* p = result->d;
	if ( !mysql_errno( p->mysql ) ) {
	    for ( ;; ) {
		MYSQL_FIELD* f = mysql_fetch_field( p->result );
		if ( f ) {
		    QSqlField fi( QString((const char*)f->name), qDecodeMYSQLType( f->type, f->flags ) );
		    fil.append( fi  );
		} else
		    break;
	    }
	}
	mysql_field_seek( p->result, 0 );
    }
    return fil;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:22,代码来源:qsql_mysql.cpp

示例14: loadMetadata

void QgsMssqlProvider::loadMetadata()
{
  mSRId = 0;
  mWkbType = QGis::WKBUnknown;

  QSqlQuery query = QSqlQuery( mDatabase );
  query.setForwardOnly( true );
  if ( !query.exec( QString( "select f_geometry_column, coord_dimension, srid, geometry_type from geometry_columns where f_table_schema = '%1' and f_table_name = '%2'" ).arg( mSchemaName ).arg( mTableName ) ) )
  {
    QString msg = query.lastError().text();
    QgsDebugMsg( msg );
  }
  if ( query.isActive() )
  {
    if ( query.next() )
    {
      mGeometryColName = query.value( 0 ).toString();
      mSRId = query.value( 2 ).toInt();
      mWkbType = getWkbType( query.value( 3 ).toString(), query.value( 1 ).toInt() );
    }
  }
}
开发者ID:PepSalehi,项目名称:Quantum-GIS,代码行数:22,代码来源:qgsmssqlprovider.cpp

示例15: setLastValues

  void FSUDaceAlgorithmRecord_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(FSUDaceAlgorithmRecord::ColumnsType::fsudaceAlgorithmType);
    OS_ASSERT(value.isValid() && !value.isNull());
    m_lastAlgorithmType = analysis::FSUDaceAlgorithmType(value.toInt());

    value = query.value(FSUDaceAlgorithmRecord::ColumnsType::fsudaceTrialType);
    if (value.isValid() && !value.isNull()) {
      m_lastTrialType = analysis::FSUDaceCvtTrialType(value.toInt());
    }
    else {
      m_lastTrialType.reset();
    }
  }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:22,代码来源:FSUDaceAlgorithmRecord.cpp


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