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


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

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


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

示例1: insertLine

//插入一行记录
bool DBModule::insertLine( const QString &title, const QString &artist, const QString &time, const QString &filePath )
{
	QSqlQuery query;
	query.prepare("insert into musicList values(?, ?, ?, ?)");
	query.addBindValue(title);
	query.addBindValue(artist);
	query.addBindValue(time);
	query.addBindValue(filePath);
	return query.exec();
}
开发者ID:appotry,项目名称:CZPlayer1.0,代码行数:11,代码来源:DBModule.cpp

示例2: saveFriends

bool Storage::saveFriends(QJsonArray data)
{
    QDateTime time;
    QString now = time.toLocalTime().toString();

    QSqlQuery query;

    query.exec("drop table friend");

    query.exec("create table friend (id INTEGER primary key autoincrement, "
               "userid varchar(30), realname varchar(30), username varchar(30), email varchar(30),"
               "image varchar(100), lastchat text, lastchattime varchar(20), lastseen varchar(30), updated varchar(30), created varchar(30))");

    qDebug() << query.lastError().databaseText();

    foreach (QJsonValue value, data) {
        QJsonObject dataObject = value.toObject();
        query.prepare("INSERT INTO friend (userid, realname, username, email, image, lastchat, lastchattime, lastseen, updated, created) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        query.addBindValue(dataObject.value("_id"));
        query.addBindValue(dataObject.value("name"));
        query.addBindValue(dataObject.value("username"));
        query.addBindValue(dataObject.value("email"));
        query.addBindValue("");
        query.addBindValue(dataObject.value("username"));
        query.addBindValue("");
        query.addBindValue(now);
        query.addBindValue(now);
        query.addBindValue(now);
        qDebug() << query.lastError().databaseText();
        query.exec();
        qDebug() << query.lastError().databaseText();

    }
开发者ID:MarmopemarZcity,项目名称:mZcv1,代码行数:33,代码来源:storage.cpp

示例3: on_buttonBox_accepted

void secondDiagnostics::on_buttonBox_accepted()
{
    QSqlQuery query;
    query.prepare("insert into diagnosis(fk_customer, fk_doctor, type, dateD, timeD) values(?, ?, 1, ?, ?)");
    query.addBindValue(custID);
    query.addBindValue(docID);
    query.addBindValue(ui->dateEdit->date());
    query.addBindValue(ui->timeEdit->time());
    query.exec();
    this->deleteLater();
}
开发者ID:seacomandor,项目名称:DetaDoc,代码行数:11,代码来源:seconddiagnostics.cpp

示例4: addToMedia

void Tag::addToMedia(int mediaId)
{
    QSqlQuery query;
    query.prepare("INSERT INTO " TABLE_MediaTags " (" KEY_MediaTags_MediaId ", " KEY_MediaTags_TagId ") VALUES(?, ?)");
    query.addBindValue(QVariant(mediaId));
    query.addBindValue(QVariant(Id));
    if(!query.exec())
    {
        QLOG_ERROR() << "Failed to add MediaTag record: " + query.lastError().text();
    }
}
开发者ID:agel,项目名称:QAmvLibrarian,代码行数:11,代码来源:tag.cpp

示例5: setL

 bool EditableSqlModel::setL(int Id, const QString &str, int l)
 {
    QSqlQuery query;
    if(l == 1)
        query.prepare("update dict set  l1 = ? where id = ?");
    else
        query.prepare("update dict set  l2 = ? where id = ?");
    query.addBindValue(str);
    query.addBindValue(Id);
    return query.exec();
 }
开发者ID:vashik,项目名称:QWord,代码行数:11,代码来源:editablesqlmodel.cpp

示例6: addWarning

bool Warning::addWarning(){

    QSqlQuery query;
      query.prepare("insert into Warning(bid,wtype,wmsg,wtime)""values(?,?,?,?)");
      query.addBindValue(this->bid);
      query.addBindValue(this->wtype);
      query.addBindValue(this->wmsg);
      query.addBindValue(this->wtime.toString("yyyy-MM-dd hh:mm:ss"));
       return query.exec();

}
开发者ID:firemariovn,项目名称:inventory-control-system,代码行数:11,代码来源:warning.cpp

示例7: insertSubAnswers

//把学生主观题答案插入主观题答案表
void DBManager::insertSubAnswers(int fpaperid,QString studentid)
{

    QSqlQuery query;
    query.prepare("insert into subanswers(fpaperid,studentid)" "values(?,?)");
    query.addBindValue(fpaperid);
    query.addBindValue(studentid);
    query.exec();
    qDebug() << "insertSubAnswers] " << query.lastError();

}
开发者ID:AlanForeverAi,项目名称:Exams,代码行数:12,代码来源:DBManager.cpp

示例8: reverse

bool book::reverse(int vipID, QDateTime bookTime, int bookRow)
{
	QSqlQuery sql;
	if (!isValid(vipID) || rowIsOccupied(bookRow, bookTime))//等VIP好了以后测试
		return false;
	sql.prepare("INSERT INTO book_record VALUES (NULL, ?, ?, ?);");
	sql.addBindValue(vipID);
	sql.addBindValue(bookTime.toString("yyyy-MM-dd h:m:s"));
	sql.addBindValue(bookRow);
	return sql.exec();
}
开发者ID:zweecn,项目名称:Bowling,代码行数:11,代码来源:book.cpp

示例9: add

bool CanceledOrder::add(Model::CanceledOrder canceledOrder)
{
    DatabaseManager mgr;
    QSqlQuery query;

    query.prepare("INSERT INTO order_canceled(order_id, cancel_time) VALUES(?,?)");
    query.addBindValue(canceledOrder.order().id());
    query.addBindValue(QDateTime::currentDateTime());

    return query.exec();
}
开发者ID:AmiZya,项目名称:mangotalaat,代码行数:11,代码来源:canceledorder.cpp

示例10: insertSpriteRecord

QSqlQuery DatabaseManager::insertSpriteRecord(const SpriteModel& spriteModel) {
    QSqlQuery query;
    query.prepare("INSERT Into Sprite (SPRITE_TYPE_ID, X, Y) VALUES(?,?,?)");
    query.addBindValue(spriteModel.getSpriteTypeId());
    query.addBindValue(spriteModel.getX());
    query.addBindValue(spriteModel.getY());
    query.exec();
    QSqlQuery query2;
    query2.prepare("SELECT * FROM Sprite ORDER BY SPRITE_ID DESC");
    query2.exec();
    return query2;
}
开发者ID:prplmnky,项目名称:petn9,代码行数:12,代码来源:databasemanager.cpp

示例11: getValuesFromDatabase

Database::MarkParameters Database::getValuesFromDatabase(int id_question)
{
    QSqlQuery query;
    query.prepare("SELECT ef, counter, date, interval "
                  "FROM marks "
                  "WHERE id_user = ? AND id_question = ?");
    query.addBindValue(currentUserId_);
    query.addBindValue(id_question);
    query.exec();
    query.next();
    return MarkParameters(query.value(0).toDouble(), query.value(1).toInt(), query.value(2).toLongLong(), query.value(3).toInt());
}
开发者ID:MJKaminski,项目名称:QuickMem,代码行数:12,代码来源:database.cpp

示例12: is_white

bool DataBase::is_white(int id_game, QString &id_player){
    cout << "is_white()" <<endl;
    QSqlQuery query;
    query.prepare(QString("SELECT * FROM games WHERE id = ? AND player_1 = ?;"));
    query.addBindValue(id_game);
    query.addBindValue(id_player);
    if(!query.exec()){
        cout << query.lastError().text().toStdString() << endl;
        return false;
    }
    return query.next();
}
开发者ID:NickolayStorm,项目名称:usatu-learning,代码行数:12,代码来源:database.cpp

示例13: addEntry

bool SnippetModel::addEntry(QString title, QString tags, QString language, QString code)
{
    QSqlQuery query;
    query.prepare("INSERT INTO SNIPPETS(id, title, tags, language, code) values(NULL, ?, ? ,?,?)");
    query.addBindValue(title);
    query.addBindValue(tags);
    query.addBindValue(language);
    query.addBindValue(code);

    if(query.exec()) return true;
    return false;
}
开发者ID:AmiZya,项目名称:qsnippets,代码行数:12,代码来源:snippetmodel.cpp

示例14: on_pbAggiungiPermesso_clicked

void FormGestioneFerie::on_pbAggiungiPermesso_clicked()
{
    for(QDate a=ui->dePermessiDal->date(); a.operator <=( ui->dePermessiAl->date());a= a.addDays(1) )
   {

    qDebug() << "Permesso per "+ui->cbMatricola->currentText()+" per il giorno "+a.toString("dd/MM/yyyy");


    QSqlQuery query;
    query.prepare("INSERT INTO assenze (ID, matricola, causa, data)" "VALUES (?, ?, ?, ?)");
   // query.addBindValue( ui->cbMatricola->currentText()+"_"+ui->dePermessiDal->date().toString("dd/MM/yyyy"));
    query.addBindValue( ui->cbMatricola->currentText()+"_"+a.toString("dd/MM/yyyy"));
    query.addBindValue( ui->cbMatricola->currentText());
    query.addBindValue( ui->cbTipoPermesso->currentText());
   // query.addBindValue( ui->dePermessiDal->date().toString("dd/MM/yyyy"));
    query.addBindValue( a.toString("dd/MM/yyyy"));
    if(query.exec())
    {
        QMessageBox msgBox;
        msgBox.setText("Inserzione nel database.");
        msgBox.setInformativeText(QString("Permesso per il giorno %1 inserito correttamente.").arg(a.toString("dd/MM/yyyy")));
        msgBox.setStandardButtons(QMessageBox::Ok );
        msgBox.setIcon(QMessageBox::Information);
        msgBox.exec();
    }
    else
    {
        QMessageBox msgBox;
        msgBox.setText("Inserzione nel database.");
        msgBox.setInformativeText(QString("Permesso per il giorno %1 NON inserito nel database. Probabilmente è gia stato inserito un permesso per lo stesso giorno.").arg(a.toString("dd/MM/yyyy")));
        msgBox.setStandardButtons(QMessageBox::Ok );
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.exec();
    }

    QSqlTableModel *model = new QSqlTableModel(this, this->db);
    model->setTable("assenze");
    model->setEditStrategy(QSqlTableModel::OnFieldChange);
    model->select();
    model->setFilter(QString("Matricola=\"%1\"").arg(ui->cbMatricola->currentText()));

    model->sort(2,Qt::AscendingOrder);
      model->setHeaderData(1, Qt::Horizontal, tr("MATRICOLA"));
      model->setHeaderData(2, Qt::Horizontal, tr("DATA"));
      model->setHeaderData(3, Qt::Horizontal, tr("CAUSA"));
      ui->tvPermessi->setModel(model);
      ui->tvPermessi->hideColumn(0);
      ui->tvPermessi->resizeColumnsToContents();
      ui->tvPermessi->resizeRowsToContents();
      ui->tvPermessi->selectRow(0);

  }
}
开发者ID:giorgioPollaccia,项目名称:turniOsa,代码行数:53,代码来源:formgestioneferie.cpp

示例15: writeShieldHis

void Database::writeShieldHis()
{

    QSqlDatabase::database().transaction();
    QDateTime datetime = QDateTime::currentDateTime();
    QSqlQuery query;
    query.setForwardOnly(true);

    query.prepare("INSERT INTO shieldhis( time,unitid,type)"
                  "VALUES ( ?, ?,?)");

    query.addBindValue(datetime);
    query.addBindValue(0x01000000);
    query.addBindValue(0x00FFFF00);

    bool bSuccess = query.exec();
    if (!bSuccess)
    {
        QSqlError lastError = query.lastError();
        qDebug() << lastError.driverText()
                 <<QString(QObject::tr("in datebase : insert soundandalarmdevice into the shieldhis error"));
    }

//    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 shieldhis( time,unitid,type)"
//                  "VALUES ( ?, ?,?)");

//    int host = 1;
//    int iobr = 1;
//    int loop = 1;


//    for (int i = 0;i<100; i++)
//    {
//        query.addBindValue(dt);
//        query.addBindValue((host<<24) | (iobr<<16) | (loop<<8) | (i+1));
//        query.addBindValue(0x000000FF);
//        bool bSuccess = query.exec();
//        if (!bSuccess)
//        {
//            QSqlError lastError = query.lastError();
//            qDebug() << lastError.driverText()
//                     <<QString(QObject::tr("insert shieldhis error"));
//        }
//    }
    /*Close the transaction*/
    QSqlDatabase::database().commit();
}
开发者ID:qingwu,项目名称:nantong,代码行数:52,代码来源:database.cpp


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