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


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

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


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

示例1: saveLouxianToDB

void boardRegThread::saveLouxianToDB()
{
    int host = 1,iobr = 33,loop = 1,node = 0;
    QSqlDatabase::database().transaction();

    QSqlQuery query1;
    bool bSuccess1 = query1.exec(QString("DELETE FROM unitset WHERE unitid >= %1 AND unitid <= %2")
                                 .arg((host<<24) | (iobr<<16) | (loop<<8) | 1)
                                 .arg((host<<24) | (iobr<<16) | (loop<<8) | 0xff));
    if (!bSuccess1)
    {
        QSqlError lastError = query1.lastError();
        qDebug() << lastError.driverText()
                 <<QString(QObject::tr("delete unitset-louxian error"));
    }

    //add by linwotian,if delete the device from the unitset,then delete the same device from the shieldhis
    QSqlQuery queryshield;
    bool bSuccess_shield = queryshield.exec(QString("DELETE FROM shieldhis WHERE unitid >= %1 AND unitid <= %2")
                                            .arg((host<<24) | (iobr<<16) | (loop<<8) | 1)
                                            .arg((host<<24) | (iobr<<16) | (loop<<8) | 0xff));

    if (!bSuccess_shield)
    {
        QSqlError lastError = queryshield.lastError();
        qDebug() << lastError.driverText()
                 <<QString(QObject::tr("delete shieldhis error"));
    }

    QSqlQuery query;
    query.clear();
    query.prepare("INSERT INTO unitset(id, regist, shield, restated, level, unitid, geo_addr, type, delay, str)"
                  "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    for (node = 1;node <= 255;node++)
    {
        query.addBindValue((iobr-1)*4*255+(loop-1)*8+node);
        (louxianReg[node-1]==LOUXIAN)?query.addBindValue(true):query.addBindValue(false);
        //(node == 0) ? query.addBindValue(true) : ((louxianReg[node-1]==LOUXIAN) ? query.addBindValue(true) : query.addBindValue(false));
        query.addBindValue(false);//initialized unshield
        query.addBindValue(false);
        query.addBindValue(false);
        query.addBindValue((host<<24) | (iobr<<16) | (loop<<8) | node);
        query.addBindValue(0x00000000);
        query.addBindValue(0x00FF0000|((int)(LOUXIAN)<<8));
        query.addBindValue(0x00000000);
        query.addBindValue(QString("%1号楼显").arg(node));

        bool bSuccess = query.exec();
        if (!bSuccess)
        {
            QSqlError lastError = query.lastError();
            qDebug() << lastError.driverText()
                     <<QString(QObject::tr("update louxian error"));
        }
    }
}
开发者ID:qingwu,项目名称:nantong,代码行数:56,代码来源:boardregthread.cpp

示例2:

/*!  \internal

  Virtual function which is called when an error has occurred The
  default implementation displays a warning message to the user with
  information about the error.

*/
void Q3DataManager::handleError(QWidget* parent, const QSqlError& e)
{
#ifndef QT_NO_MESSAGEBOX
    if (e.driverText().isEmpty() && e.databaseText().isEmpty()) {
        QMessageBox::warning (parent, QLatin1String("Warning"), QLatin1String("An error occurred while accessing the database"));
    } else {
        QMessageBox::warning (parent, QLatin1String("Warning"), e.driverText() + QLatin1Char('\n') + e.databaseText(),
                           0, 0);
    }
#endif // QT_NO_MESSAGEBOX
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:18,代码来源:q3sqlmanager_p.cpp

示例3: handleError

/*!  \internal

  Virtual function which is called when an error has occurred The
  default implementation displays a warning message to the user with
  information about the error.

*/
void QDataManager::handleError( QWidget* parent, const QSqlError& e )
{
#ifndef QT_NO_MESSAGEBOX
    if (e.driverText().isEmpty() && e.databaseText().isEmpty()) {
	QMessageBox::warning ( parent, "Warning", "An error occurred while accessing the database");
    } else {
	QMessageBox::warning ( parent, "Warning", e.driverText() + "\n" + e.databaseText(),
			   0, 0 );
    }
#endif // QT_NO_MESSAGEBOX
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:18,代码来源:qsqlmanager_p.cpp

示例4: upsertPkgItem

int Loadable::upsertPkgItem(int &pkgitemid, const int pkgheadid,
                            const int itemid, QString &errMsg)
{
  if (pkgheadid < 0)
    return 0;

  QSqlQuery select;
  QSqlQuery upsert;

  if (pkgitemid >= 0)
    upsert.prepare("UPDATE pkgitem SET pkgitem_descrip=:descrip "
                   "WHERE (pkgitem_id=:id);");
  else
  {
    upsert.prepare("SELECT NEXTVAL('pkgitem_pkgitem_id_seq');");
    upsert.exec();
    if (upsert.first())
      pkgitemid = upsert.value(0).toInt();
    else if (upsert.lastError().type() != QSqlError::NoError)
    {
      QSqlError err = upsert.lastError();
      errMsg = _sqlerrtxt.arg(_name).arg(err.driverText()).arg(err.databaseText());
      return -20;
    }
    upsert.prepare("INSERT INTO pkgitem ("
                   "    pkgitem_id, pkgitem_pkghead_id, pkgitem_type,"
                   "    pkgitem_item_id, pkgitem_name, pkgitem_descrip"
                   ") VALUES ("
                   "    :id, :headid, :type,"
                   "    :itemid, :name, :descrip);");
  }

  upsert.bindValue(":id",      pkgitemid);
  upsert.bindValue(":headid",  pkgheadid);
  upsert.bindValue(":type",    _pkgitemtype);
  upsert.bindValue(":itemid",  itemid);
  upsert.bindValue(":name",    _name);
  upsert.bindValue(":descrip", _comment);

  if (!upsert.exec())
  {
    QSqlError err = upsert.lastError();
    errMsg = _sqlerrtxt.arg(_name).arg(err.driverText()).arg(err.databaseText());
    return -21;
  }

  return pkgitemid;
}
开发者ID:gpazo,项目名称:xtuple-svn,代码行数:48,代码来源:loadable.cpp

示例5: qDebug

std::vector< Profile > DatabaseFacade::getUsers()
{
    std::vector<Profile> profiles;

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

    QSqlQuery query;
    query.exec("SELECT * FROM Gamers");

    QSqlError err = query.lastError();
    if(err.isValid())
        qDebug() << err.databaseText() << "\n" << err.driverText() << "\n" << err.nativeErrorCode();
    
    while (query.next())
    {
        int id = query.value(0).toInt();
        QString name = query.value(1).toString();

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

        profiles.emplace_back(id, name, picture);
    }

    query.clear();

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

示例6: login

void Database::login() throw (TimesheetProcessorException )
{
    MySqlStorage::Parameters parameters;
    try {
        parameters = MySqlStorage::parseParameterEnvironmentVariable();
    } catch( ParseError& e ) {
        throw TimesheetProcessorException( e.what() );
    }
    m_storage.configure( parameters );
    bool ok = m_storage.database().open();
    if ( !ok ) {
        QSqlError error = m_storage.database().lastError();

        QString msg = QObject::tr( "Cannot connect to database %1 on host %2, database said "
                                   "\"%3\", driver said \"%4\"" )
                .arg( parameters.database ) .arg( parameters.host )
                .arg( error.driverText() )
                .arg( error.databaseText() );
        throw TimesheetProcessorException( msg );
    }
    // check if the driver has transaction support
    if( ! m_storage.database().driver()->hasFeature( QSqlDriver::Transactions ) ) {
        QString msg = QObject::tr( "The database driver in use does not support transactions. Transactions are required." );
        throw TimesheetProcessorException( msg );
    }
}
开发者ID:hefee,项目名称:Charm,代码行数:26,代码来源:Database.cpp

示例7: writeIobrInfo

void Database::writeIobrInfo()
{
    QSqlDatabase::database().transaction();
    QSqlQuery query;
    query.prepare("INSERT INTO iobrinfo(id, iobrregist)"
                  "VALUES (?, ?)");
    for (int iobr = 1;iobr <= 34;iobr++)
    {
        query.addBindValue(iobr);
        query.addBindValue(false);

        //        if ( iobr == 1 )
        //        {
        //            query.addBindValue(true);
        //        }
        //        else
        //        {
        //            query.addBindValue(false);
        //        }

        bool bSuccess = query.exec();
        if (!bSuccess)
        {
            QSqlError lastError = query.lastError();
            qDebug() << lastError.driverText()
                     <<QString(QObject::tr("iobrinfo insert error"));
        }
    }
    QSqlDatabase::database().commit();
}
开发者ID:qingwu,项目名称:nantong,代码行数:30,代码来源:database.cpp

示例8: ErrorString

QString toQSqlConnectionSub::ErrorString(const QSqlError &err, const QString &sql)
{
    QString ret;
    if (err.databaseText().isEmpty())
    {
        if (err.driverText().isEmpty())
            ret = QString::fromLatin1("Unknown error");
        else
            ret = err.driverText();
    }
    else
        ret = err.databaseText();
    if (!sql.isEmpty())
        ret += QString::fromLatin1("\n\n") + sql;
    return ret;
}
开发者ID:tora-tool,项目名称:tora,代码行数:16,代码来源:toqsqlconnection.cpp

示例9: writeOperationHis

void Database::writeOperationHis()
{

    QDateTime dt = QDateTime::currentDateTime();

    /*Before the opening of each transaction,adding this code to improve the speed*/
    QSqlDatabase::database().transaction();
    QSqlQuery query;
    query.prepare("INSERT INTO operationhis(id, time, str)"
                  "VALUES (?, ?, ?)");
    for (int i = 0;i<100; i++)
    {
        query.addBindValue(i);

        query.addBindValue(dt);
        query.addBindValue(QString("操作%1").arg(i));
        bool bSuccess = query.exec();
        if (!bSuccess)
        {
            QSqlError lastError = query.lastError();
            qDebug() << lastError.driverText()
                     <<QString(QObject::tr("insert operationhis error"));
        }
    }
    /*Close the transaction*/
    QSqlDatabase::database().commit();
}
开发者ID:qingwu,项目名称:nantong,代码行数:27,代码来源:database.cpp

示例10: writeFireHis

void Database::writeFireHis()
{
    int host = 1;
    int iobr = 1;
    int loop = 3;
    int node = 16;
    int infoid = (host<<24) | (iobr<<16) | (loop<<8) | node;
    int geo_addr = (host<<24) | (iobr<<16) | (loop<<8) | node;
    QDateTime dt = QDateTime::currentDateTime();

    /*Before the opening of each transaction,adding this code to improve the speed*/
    QSqlDatabase::database().transaction();
    QSqlQuery query;
    query.prepare("INSERT INTO firehis(id, type, infoid, geo_addr, time, str)"
                  "VALUES (?, ?, ?, ?, ?, ?)");
    for (int i = 0;i<100; i++)
    {
        query.addBindValue(i);
        query.addBindValue(0x000B4000);

        query.addBindValue(infoid);
        query.addBindValue(geo_addr);
        query.addBindValue(dt);
        query.addBindValue(QString("华中科技大学南一楼%1室").arg(i));
        bool bSuccess = query.exec();
        if (!bSuccess)
        {
            QSqlError lastError = query.lastError();
            qDebug() << lastError.driverText()
                     <<QString(QObject::tr("insert firehis error"));
        }
    }
    /*Close the transaction*/
    QSqlDatabase::database().commit();
}
开发者ID:qingwu,项目名称:nantong,代码行数:35,代码来源:database.cpp

示例11: notify

bool Application::notify(QObject * receiver, QEvent * e)
{
	try
	{
		return QApplication::notify(receiver, e);
	}
	catch (Exception & e)
	{
		qCritical() << e.title() << ':' << e.description();
		QMessageBox::critical(nullptr, e.title(), e.description());
	}
	catch (QSqlQuery & q)
	{
		QString s;
		QTextStream str(&s);
		QSqlError e = q.lastError();

		str << "Query: " << q.lastQuery() << '\n';
		str << "Driver text: " << e.driverText() << '\n';
		str << "Database text: " << e.databaseText() << '\n';
		str << "Native error code: " << e.nativeErrorCode();
		qCritical() << "Database error:" << s;
		QMessageBox::critical(nullptr, "Database error", s);
	}

	return false;
}
开发者ID:wakeofluna,项目名称:qlivestream,代码行数:27,代码来源:application.cpp

示例12: 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

示例13: 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

示例14:

QT_BEGIN_NAMESPACE

#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QSqlError &s)
{
    dbg.nospace() << "QSqlError(" << s.number() << ", " << s.driverText() <<
                     ", " << s.databaseText() << ')';
    return dbg.space();
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:9,代码来源:qsqlerror.cpp

示例15: addUserStat

void DatabaseFacade::addUserStat( int userId, const QString& gameName_, int score_ )
{
    if(!connected)
    {
        qDebug() << "Not connected to database";
        return;
    }

    QSqlQuery query;
    QSqlQuery query2;

    qDebug() << "Executing query : \n\t" << queryGetGamerHighScore.arg(gameName_).arg(userId);
    query.exec(queryGetGamerHighScore.arg(gameName_).arg(userId));

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

    if(query.next())
    {
        if(query.value(1).toInt() < score_)
        {
            qDebug() << "Executing query : \n\t" << queryUpdateHighScore.arg(score_).arg(query.value(0).toString()).arg(userId);
            query2.exec(queryUpdateHighScore.arg(score_).arg(query.value(0).toString()).arg(userId));

            err = query2.lastError();
            if(err.isValid())
                qDebug() << err.databaseText() << "\n" << err.driverText() << "\n" << err.nativeErrorCode();
        }
    }
    else
    {
        qDebug() << "Executing query : \n\t" << queryInsertHighScore.arg(userId).arg(gameName_).arg(score_);
        query2.exec(queryInsertHighScore.arg(userId).arg(gameName_).arg(score_));

        err = query2.lastError();
        if(err.isValid())
            qDebug() << err.databaseText() << "\n" << err.driverText() << "\n" << err.nativeErrorCode();
    }
}
开发者ID:Flash2307,项目名称:PlayGround,代码行数:40,代码来源:DatabaseFacade.cpp


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