int x=0;
int numrecords= db.recordcount;
while(x<=numrecords){
theQuery="";
theQuery ="INSERT INTO reporttemplates (reportname,itemtag,itemposx,itemposy,scale,angle,zvalue,data,originalrect,currentrect,";
theQuery =theQuery+"type,fontindex,color,fntsize,isbold,isitalic,isunderlined,pagenum,showonallpages,opacity)";
theQuery =theQuery+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
query.prepare(theQuery);
query.bindValue(0,ui->lineEdit->text());
query.bindValue(1,db->getCell(row,0));
query.bindValue(2,db->getCell(row,1));
query.bindValue(3,db->getCell(row,2));
query.bindValue(4,db->getCell(row,3));
query.bindValue(5,db->getCell(row,4));
query.bindValue(6,db->getCell(row,5));
query.bindValue(7,db->getCell(row,6));
query.bindValue(8,db->getCell(row,7));
query.bindValue(9,db->getCell(row,8));
query.bindValue(10,db->getCell(row,9));
query.bindValue(11,db->getCell(row,10));
query.bindValue(12,db->getCell(row,11));
query.bindValue(13,db->getCell(row,12));
query.bindValue(14,db->getCell(row,13));
query.bindValue(15,db->getCell(row,14));
query.bindValue(16,db->getCell(row,15));
query.bindValue(17,db->getCell(row,16));
query.bindValue(18,db->getCell(row,17));
query.bindValue(19,db->getCell(row,18));
qDebug() << query.exec(); <- works correctly one time , next returns false.
query.next(); <-try to move to last row
qDebug
() << query.
lastError(); <
-2nd
time returns
QSqlError(19,
"unable to fetch row",
"constraint failed")x++
}
int x=0;
int numrecords= db.recordcount;
while(x<=numrecords){
QString theQuery;
QSqlQuery query(theQuery, templatedb) ;
theQuery="";
theQuery ="INSERT INTO reporttemplates (reportname,itemtag,itemposx,itemposy,scale,angle,zvalue,data,originalrect,currentrect,";
theQuery =theQuery+"type,fontindex,color,fntsize,isbold,isitalic,isunderlined,pagenum,showonallpages,opacity)";
theQuery =theQuery+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
query.prepare(theQuery);
query.bindValue(0,ui->lineEdit->text());
query.bindValue(1,db->getCell(row,0));
query.bindValue(2,db->getCell(row,1));
query.bindValue(3,db->getCell(row,2));
query.bindValue(4,db->getCell(row,3));
query.bindValue(5,db->getCell(row,4));
query.bindValue(6,db->getCell(row,5));
query.bindValue(7,db->getCell(row,6));
query.bindValue(8,db->getCell(row,7));
query.bindValue(9,db->getCell(row,8));
query.bindValue(10,db->getCell(row,9));
query.bindValue(11,db->getCell(row,10));
query.bindValue(12,db->getCell(row,11));
query.bindValue(13,db->getCell(row,12));
query.bindValue(14,db->getCell(row,13));
query.bindValue(15,db->getCell(row,14));
query.bindValue(16,db->getCell(row,15));
query.bindValue(17,db->getCell(row,16));
query.bindValue(18,db->getCell(row,17));
query.bindValue(19,db->getCell(row,18));
qDebug() << query.exec(); <- works correctly one time , next returns false.
query.next(); <-try to move to last row
qDebug() << query.lastError(); <-2nd time returns QSqlError(19,"unable to fetch row", "constraint failed")
x++
}
To copy to clipboard, switch view to plain text mode
Bookmarks