本文整理汇总了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);
}
}
示例2: createTablesOfTheRegisters
void DataBase::createTablesOfTheRegisters(QList<FRegister *> ®isters)
{
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 = "";
}
}
示例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);
}
示例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 = "";
}
}
示例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;
}
示例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 = "";
}
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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() );
}
}
}
示例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();
}
}