本文整理汇总了C++中QSqlQuery::boundValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQuery::boundValue方法的具体用法?C++ QSqlQuery::boundValue怎么用?C++ QSqlQuery::boundValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlQuery
的用法示例。
在下文中一共展示了QSqlQuery::boundValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolveOutput
void QxSqlQuery::resolveOutput(QSqlQuery & query, bool bFetchSqlResult)
{
bool bKey = (qx::QxSqlDatabase::getSingleton()->getSqlPlaceHolderStyle() != qx::QxSqlDatabase::ph_style_question_mark);
//qDebug() << "start resolveOutput";
for (long l = 0; l < m_lstValue.count(); l++)
{
type_bind_value val = m_lstValue.getByIndex(l);
if (val.get<1>() == QSql::In) { continue; }
if (bKey) { val.get<0>() = query.boundValue(m_lstValue.getKeyByIndex(l)); }
else { val.get<0>() = query.boundValue(l); }
}
//qDebug() << "finish resolveOutput";
if (bFetchSqlResult) { fetchSqlResult(query); }
}
示例2: QSqlQuery_snippets
void QSqlQuery_snippets()
{
{
// typical loop
//! [7]
QSqlQuery query("SELECT country FROM artist");
while (query.next()) {
QString country = query.value(0).toString();
doSomething(country);
}
//! [7]
}
{
// field index lookup
//! [8]
QSqlQuery query("SELECT * FROM artist");
int fieldNo = query.record().indexOf("country");
while (query.next()) {
QString country = query.value(fieldNo).toString();
doSomething(country);
}
//! [8]
}
{
// named with named
//! [9]
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (:id, :forename, :surname)");
query.bindValue(":id", 1001);
query.bindValue(":forename", "Bart");
query.bindValue(":surname", "Simpson");
query.exec();
//! [9]
}
{
// positional with named
//! [10]
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (:id, :forename, :surname)");
query.bindValue(0, 1001);
query.bindValue(1, "Bart");
query.bindValue(2, "Simpson");
query.exec();
//! [10]
}
{
// positional 1
//! [11]
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (?, ?, ?)");
query.bindValue(0, 1001);
query.bindValue(1, "Bart");
query.bindValue(2, "Simpson");
query.exec();
//! [11]
}
{
// positional 2
//! [12]
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (?, ?, ?)");
query.addBindValue(1001);
query.addBindValue("Bart");
query.addBindValue("Simpson");
query.exec();
//! [12]
}
{
// stored
//! [13]
QSqlQuery query;
query.prepare("CALL AsciiToInt(?, ?)");
query.bindValue(0, "A");
query.bindValue(1, 0, QSql::Out);
query.exec();
int i = query.boundValue(1).toInt(); // i is 65
//! [13]
Q_UNUSED(i);
}
QSqlQuery query;
{
// examine with named binding
//! [14]
QMapIterator<QString, QVariant> i(query.boundValues());
while (i.hasNext()) {
i.next();
cout << i.key().toUtf8().data() << ": "
<< i.value().toString().toUtf8().data() << endl;
//.........这里部分代码省略.........
示例3: apply
void FrmFrame::apply()
{
bool bError=false;
//We call a stored procedure to see if there are GLS available outside the bin
QSqlQuery query;
query.setForwardOnly(true);
int id= cmbPrexistent->model()->index(cmbPrexistent->currentIndex(),0).data().toInt();
int n=0;
query.prepare("{CALL spCountGLS4Frame(?,?)}");
query.bindValue(0,id);
query.bindValue("Number",n,QSql::Out);
if (!query.exec()){
emit showError(query.lastError().text());
bError=true;;
}
n = query.boundValue("Number").toInt();
if (n<1){
emit showError(tr("There are no Group of Landing Sites for this frame!"));
bError=true;
}else{
//First insert the dates...
if (!mapperStartDt->submit() || !mapperEndDt->submit()){
if (m_tDateTime->lastError().type()!=QSqlError::NoError)
emit showError(m_tDateTime->lastError().text());
else
emit showError(tr("Could not submit mapper!"));
bError=true;
}
else{
if (!m_tDateTime->submitAll()){
if (m_tDateTime->lastError().type()!=QSqlError::NoError)
emit showError(m_tDateTime->lastError().text());
else
emit showError(tr("Could not write DateTime in the database!"));
bError=true;
}
}
while(m_tDateTime->canFetchMore())
m_tDateTime->fetchMore();
mapperStartDt->setCurrentIndex(m_tDateTime->rowCount()-2);
mapperEndDt->setCurrentIndex(m_tDateTime->rowCount()-1);
int startIdx=mapperStartDt->currentIndex();
int endIdx=mapperEndDt->currentIndex();
if (bError) {
emit showError(tr("Could not create dates in the database!"));
}else{
//Now insert the record
while(tFrameTime->canFetchMore())
tFrameTime->fetchMore();
tFrameTime->insertRow(tFrameTime->rowCount());
QModelIndex idx=tFrameTime->index(tFrameTime->rowCount()-1,1);//id frame
if (idx.isValid()){
int idFrame;
if (getCurrentFrame(idFrame)){
tFrameTime->setData(idx,idFrame);
QModelIndex idx=tFrameTime->index(tFrameTime->rowCount()-1,2);//start dt
if (idx.isValid()){
int idStart;
if (getDtId(startIdx,idStart)){
tFrameTime->setData(idx,idStart);
idx=tFrameTime->index(tFrameTime->rowCount()-1,3);//end dt
if (idx.isValid()){
int idEnd;
if (getDtId(endIdx,idEnd)){
tFrameTime->setData(idx,idEnd);
}else bError=true;
}
}else bError=true;
}else bError=true;
}else bError=true;
}else bError=true;
}
bError=!tFrameTime->submitAll();
}
if (!bError){
QList<QWidget*> lWidgets;
lWidgets << this->groupPhysical;
lWidgets << this->groupTime;
emit lockControls(true,lWidgets);
}else{
if (tFrameTime->lastError().type()!=QSqlError::NoError)
emit showError(tFrameTime->lastError().text());
}
pushNext->setEnabled(!bError);
//.........这里部分代码省略.........