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


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

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


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

示例1: newentry

void dataeditfrm::newentry()
{
    //prepare supplier entry
    int i, ii;
    QString supl = "";
    for(i=0;i<tabsuppliers->rowCount();i++)
    {
    	for(ii=0; ii<tabsuppliers->columnCount(); ii++)
    	{
    		QTableWidgetItem *item = new QTableWidgetItem;
    		item = tabsuppliers->item(i, ii);
    		if(item != 0)
    			supl += tabsuppliers->item(i, ii)->text() + ":#:";
			supl = supl.leftJustified(supl.length()-1, '.', true) + "#:";
   		}
   	}
    
    QString state = "0";
    if(chkactive->isChecked())
		state = "1";
    QString connstr = QString("INSERT INTO `"+lbldatatab->text()+"` (`ID`, `col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`) VALUES (NULL, '%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9'").arg(txtlabel->text()).arg(txtdescription->toPlainText()).arg(txtstock->text()).arg(txtminquantity->text()).arg(txtunit->text()).arg(txtorderquantity->text()).arg(txtpurchaseprice->text()).arg(txtsellprice->text()).arg(supl);
    connstr += QString(", '%1', '%2', '%3', '%4', '%5', '%6'").arg(txtpackage->text()).arg(txtweight->text()).arg(cmbvat->currentIndex()).arg(state).arg(txtwebname->text()).arg(txtwebimage->text());
    connstr += QString(", '%1', '%2', '%3', '%4', '%5', '%6');").arg(txtweburl->text()).arg(QDate::currentDate().toString("yyyy-MM-dd")).arg(QDate::currentDate().toString("yyyy-MM-dd")).arg(txtsalesdate->date().toString("yyyy-MM-dd")).arg(txtcomments->toPlainText()).arg(txtstockpos->text());
    QSqlQuery query(connstr);
    
    QSqlError qerror = query.lastError();
	if(qerror.isValid())
		QMessageBox::information ( 0, tr ( "Error during update..." ), qerror.text() );
}
开发者ID:BackupTheBerlios,项目名称:first4-svn,代码行数:29,代码来源:dataeditfrm.cpp

示例2: loadTranslationLanguages

void QuranDbHelper::loadTranslationLanguages(){
	QString query = "SELECT * from translations";
	if (!mDb.isOpen()){
			if (!initDatabase()) {
				qDebug() << "fail to open database " << AyatDataModel::mQuranDatabase;
			} else {
				qDebug() << "succes open database " << AyatDataModel::mQuranDatabase;
			}
		}
		// Execute the query.
		QSqlQuery sqlQuery(query, mDb);


		QSqlError err = sqlQuery.lastError();

		if (err.isValid()) {
			qWarning() << "SQL reported an error for query: " << query << " error: "
					<< mDb.lastError().text();
			return;
		}else{ // tidak ada error
			while(sqlQuery.next()){
				qDebug() << "Result: " << sqlQuery.value(0).toString() << sqlQuery.value(1).toString();
			}
		}
}
开发者ID:ferdirn,项目名称:Quran,代码行数:25,代码来源:QuranDbHelper.cpp

示例3: qDebug

std::vector< Score > DatabaseFacade::getHightScores( const QString& gameName_, int limit_ )
{
    std::vector< Score > scores;

    if(!connected)
    {
        qDebug() << "Not connected to database";
        return scores;
    }

    QSqlQuery query;
    query.exec(queryGetHighScores.arg(gameName_));

    QSqlError err = query.lastError();
    if(err.isValid())
        qDebug() << err.databaseText() << "\n" << err.driverText() << "\n" << err.nativeErrorCode();

    while (query.next())
    {
        QString name = query.value(0).toString();

        QPixmap picture;
        picture.loadFromData(query.value(1).toByteArray());

        int score = query.value(2).toInt();

        scores.emplace_back(name, picture, score);
    }

    query.clear();

    return scores;
}
开发者ID:Flash2307,项目名称:PlayGround,代码行数:33,代码来源:DatabaseFacade.cpp

示例4: call_query

QSqlError QrSqlHelper::call_query(QrSqlQuery &query, QSqlDatabase *database /* = nullptr */)
{
    QSqlError dbError;
    if (dbError.isValid()) {
        return dbError;
    }

    QSqlQuery qQuery = QSqlQuery(*database);
    qQuery.setForwardOnly(true);

    QTime timeQuery;
    timeQuery.start ();
    qQuery.prepare (query.query ());
    query.resolve(qQuery);

    if (! qQuery.exec ()) {
        qDebug() << "query exec fail, " << query.query ();
        return qQuery.lastError ();
    }
    query.resolveOutput(qQuery, true);

    int ms = timeQuery.elapsed ();
    //  set is print sql query statement or not
    if (QrSqlConfig::getInstance ()->getTraceSqlQuery ()) {
        qDebug() << "custom sql query "<< "(" <<ms << " ms) : " << query.query ()
                 << " by " << database;
    }

    return QSqlError();
}
开发者ID:Qters,项目名称:QrOrm,代码行数:30,代码来源:qrsqlhelper.cpp

示例5: add

int PushDAO::add(const Push &push)
{
    int insertId = -1;
    QSqlQuery sqlQuery(SQLConnection());

    const QString query("INSERT INTO push (seqnum, pushdate, type, pushtime, extension, content, unread)"
                        "VALUES(:seqnum, :pushdate, :type, :pushtime, :extension, :content, :unread)");

    sqlQuery.prepare(query);

    sqlQuery.bindValue(":pushdate", push.pushDateAsString());
    sqlQuery.bindValue(":type", push.contentType());
    sqlQuery.bindValue(":pushtime", push.pushTime());
    sqlQuery.bindValue(":extension", push.fileExtension());
    sqlQuery.bindValue(":content", push.content().toBase64(), QSql::In | QSql::Binary);
    sqlQuery.bindValue(":unread", push.unread());
    sqlQuery.exec();

    const QSqlError err = sqlQuery.lastError();

    if (err.isValid()) {
        qWarning() << "Error executing SQL statement: " << query << ". ERROR: " << err.text();
    } else {
        if (sqlQuery.lastInsertId().isValid()) {
            insertId = sqlQuery.lastInsertId().toInt();
        }
    }

    return insertId;
}
开发者ID:ProLove365,项目名称:Cascades-Samples,代码行数:30,代码来源:PushDAO.cpp

示例6: setLastError

void SQLiteDriver::setLastError(const QSqlError& e)
{
#if defined(SQLITEDRIVER_DEBUG)
    if (e.isValid())
        qDebug() << "SQLite error:" << e.driverText() << e.databaseText();
#endif
    QSqlDriver::setLastError(e);
}
开发者ID:Helgion,项目名称:quiterss,代码行数:8,代码来源:sqlitedriver.cpp

示例7: lastErrorText

QString Query::lastErrorText() const
{
	QString ret;
	QSqlError err = lastError();
	if(err.isValid()) {
		ret = err.text();
	}
	return ret;
}
开发者ID:viktorm2015,项目名称:quickbox,代码行数:9,代码来源:query.cpp

示例8: checkMySQLError

void checkMySQLError(QSqlQuery& q) {
    QSqlError e = q.lastError();
    if(!e.isValid())
        return;//no error
    qDebug()<<"got MySQL-Error"<<e.number()<<e.text()<<"/"<<e.databaseText()<<"/"<<e.driverText();
    qDebug()<<"on query"<<q.lastQuery();
    qDebug()<<"Terminating Application";
    QCoreApplication::quit();
}
开发者ID:Ranlvor,项目名称:crosstweeter,代码行数:9,代码来源:crossTweeter.cpp

示例9: ExtractError

//Return Values
//True:     Error Occurred
//False:    No Error Occurred / Detected
//------------------------------------------------------------------------
bool DRCDB::ExtractError(const QSqlError &error_object)
{
    DB_ERROR = error_object.isValid();

    if (DB_ERROR)
        LastErrors.push_back(error_object.text());

    return DB_ERROR;
}
开发者ID:jadmr,项目名称:cpts483_Summer2015_drc,代码行数:13,代码来源:drcdb.cpp

示例10: runtime_error

void UniPAX::mysql::MySQLManager::exec(QSqlQuery& query, QString error)
{
	query.exec();
	QSqlError e = query.lastError();
	if (e.isValid())
	{
		throw std::runtime_error(error.toStdString() + ": " + e.text().toStdString() + " -- " + query.lastQuery().toStdString());
	}
}
开发者ID:thortiede,项目名称:unipax,代码行数:9,代码来源:MySQLManager.cpp

示例11: inserttemplate

void templateeditfrm::inserttemplate()
{
	QString qstr = QString("INSERT INTO `templates` ( `ID` , `name` , `description` , `data` , `created_by` , `created` ) VALUES ('', '%1', '%2', '%3', '%4', '%5');").arg(txtname->text()).arg(txtdescription->toPlainText()).arg(txtdata->toPlainText().replace("\\", "\\\\")).arg(username).arg(QDate::currentDate().toString("yyyy-MM-dd"));
	QSqlQuery query(qstr);
	QSqlError qerror = query.lastError();
	if(qerror.isValid())
		QMessageBox::warning ( 0, tr ( "Template not saved..." ), qerror.text());
	QMessageBox::information( 0, tr ( "Template saved..." ), tr ( "Template successfully saved in the database." ) );
	this->close();
}
开发者ID:BackupTheBerlios,项目名称:first4-svn,代码行数:10,代码来源:templateeditfrm.cpp

示例12: removeLieu

void PlanningModel::removeLieu(Lieu lieu)
{
    QSqlError error = qx::dao::delete_by_id(lieu);
    if( ! error.isValid())
    {
        qDebug() << error;
    }
    qx::dao::fetch_all(lieux);
    emit refresh();
}
开发者ID:padenot,项目名称:PlanningMaker,代码行数:10,代码来源:planningmodel.cpp

示例13: removeOrga

void PlanningModel::removeOrga(Orga orga)
{
    QSqlError error = qx::dao::delete_by_id(orga);
    if( ! error.isValid())
    {
        qDebug() << error;
    }
    qx::dao::fetch_all(orgas);
    emit refresh();
}
开发者ID:padenot,项目名称:PlanningMaker,代码行数:10,代码来源:planningmodel.cpp

示例14: removeCategorie

void PlanningModel::removeCategorie(Categorie categorie)
{
    QSqlError error = qx::dao::delete_by_id(categorie);
    if( ! error.isValid())
    {
        qDebug() << error;
    }
    qx::dao::fetch_all(categories);
    emit refresh();
}
开发者ID:padenot,项目名称:PlanningMaker,代码行数:10,代码来源:planningmodel.cpp

示例15: removeEquipe

void PlanningModel::removeEquipe(Equipe equipe)
{
    QSqlError error = qx::dao::delete_by_id(equipe);
    if( ! error.isValid())
    {
        qDebug() << error;
    }
    qx::dao::fetch_all(equipes);
    emit refresh();
}
开发者ID:padenot,项目名称:PlanningMaker,代码行数:10,代码来源:planningmodel.cpp


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