本文整理汇总了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() );
}
示例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();
}
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例7: lastErrorText
QString Query::lastErrorText() const
{
QString ret;
QSqlError err = lastError();
if(err.isValid()) {
ret = err.text();
}
return ret;
}
示例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();
}
示例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;
}
示例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());
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}