dbConnect();
archiveDbConnect();
QSqlQuery archiveDataQry
("SELECT * FROM userlogevents7", m_selectDataBase
);
int id;
if(archiveDataQry.exec()){
qDebug()<<"sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with sql statement";
qDebug() << archiveDataQry.lastError();
}
m_selectDataBase.transaction();
if(copyDataQry.prepare("INSERT INTO usereventarchive (id, userName, eventMessage, dateTime) VALUES (:id, :userName, :eventMessage, :dateTime)"))
{
qDebug()<<"prepare sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with prepare sql statement";
qDebug() << copyDataQry.lastError();
}
while(archiveDataQry.next()){
id = archiveDataQry.record().value(0).toInt();
userName = archiveDataQry.record().value(1).toString();
eventMessage = archiveDataQry.record().value(2).toString();
dateTime = archiveDataQry.record().value(3).toDate();
copyDataQry.bindValue(0,id);
copyDataQry.bindValue(1, userName);
copyDataQry.bindValue(2, eventMessage);
copyDataQry.bindValue(3, dateTime);
if(copyDataQry.exec()){
qDebug()<<"copy sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with copy sql statement";
qDebug() << copyDataQry.lastError();
}
}
m_selectDataBase.commit();
m_selectDataBase.close();
}
dbConnect();
archiveDbConnect();
QSqlQuery archiveDataQry("SELECT * FROM userlogevents7", m_selectDataBase);
QSqlQuery copyDataQry(m_archiveDataBase);
int id;
QString userName;
QString eventMessage;
QDate dateTime;
if(archiveDataQry.exec()){
qDebug()<<"sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with sql statement";
qDebug() << archiveDataQry.lastError();
}
m_selectDataBase.transaction();
if(copyDataQry.prepare("INSERT INTO usereventarchive (id, userName, eventMessage, dateTime) VALUES (:id, :userName, :eventMessage, :dateTime)"))
{
qDebug()<<"prepare sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with prepare sql statement";
qDebug() << copyDataQry.lastError();
}
while(archiveDataQry.next()){
id = archiveDataQry.record().value(0).toInt();
userName = archiveDataQry.record().value(1).toString();
eventMessage = archiveDataQry.record().value(2).toString();
dateTime = archiveDataQry.record().value(3).toDate();
copyDataQry.bindValue(0,id);
copyDataQry.bindValue(1, userName);
copyDataQry.bindValue(2, eventMessage);
copyDataQry.bindValue(3, dateTime);
if(copyDataQry.exec()){
qDebug()<<"copy sql statement exicuted fine";
}
else{
qDebug() << "Errors accured with copy sql statement";
qDebug() << copyDataQry.lastError();
}
}
m_selectDataBase.commit();
m_selectDataBase.close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks