rogerholmes
29th December 2009, 21:35
I am trying to insert several rows into sqlite database, i have searched this fourm and the net but still can not get this to work, it just inserts the first row correctly but nothing is inserted after the first row. I have verified the query is updated to the correct values on each loop. can you help me?:)
templatedb.transaction();
while(!db->eof()){
theQuery="";
theQuery ="INSERT INTO reporttemplates (reportname ,itemtag,itemposx,itemposy,scale,angle,zvalue,data ,originalrect,currentrect,";
theQuery =theQuery+"type,fontindex,color,fntsize,isbold,isitalic,isund erlined,pagenum,showonallpages,opacity)";
theQuery =theQuery+ " VALUES('"+ui->lineEdit->text()+"','"+db->getCell(db->currentRow(),0)+"','"+db->getCell(db->currentRow(),1)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),2)+"','"+db->getCell(db->currentRow(),3)+"','"+db->getCell(db->currentRow(),4)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),5)+"','"+db->getCell(db->currentRow(),6)+"','"+db->getCell(db->currentRow(),7)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),8)+"','"+db->getCell(db->currentRow(),9)+"','"+db->getCell(db->currentRow(),10)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),11)+"','"+db->getCell(db->currentRow(),12)+"','"+db->getCell(db->currentRow(),13)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),14)+"','"+db->getCell(db->currentRow(),15)+"','"+db->getCell(db->currentRow(),16)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),17)+"','"+db->getCell(db->currentRow(),18)+"')" ;
templatedb.exec(theQuery);
db->next();
int row =db->currentRow();
}
templatedb.exec("COMMIT");
templatedb.transaction();
while(!db->eof()){
theQuery="";
theQuery ="INSERT INTO reporttemplates (reportname ,itemtag,itemposx,itemposy,scale,angle,zvalue,data ,originalrect,currentrect,";
theQuery =theQuery+"type,fontindex,color,fntsize,isbold,isitalic,isund erlined,pagenum,showonallpages,opacity)";
theQuery =theQuery+ " VALUES('"+ui->lineEdit->text()+"','"+db->getCell(db->currentRow(),0)+"','"+db->getCell(db->currentRow(),1)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),2)+"','"+db->getCell(db->currentRow(),3)+"','"+db->getCell(db->currentRow(),4)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),5)+"','"+db->getCell(db->currentRow(),6)+"','"+db->getCell(db->currentRow(),7)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),8)+"','"+db->getCell(db->currentRow(),9)+"','"+db->getCell(db->currentRow(),10)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),11)+"','"+db->getCell(db->currentRow(),12)+"','"+db->getCell(db->currentRow(),13)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),14)+"','"+db->getCell(db->currentRow(),15)+"','"+db->getCell(db->currentRow(),16)+"',";
theQuery =theQuery+"'"+db->getCell(db->currentRow(),17)+"','"+db->getCell(db->currentRow(),18)+"')" ;
templatedb.exec(theQuery);
db->next();
int row =db->currentRow();
}
templatedb.exec("COMMIT");