homerun4711
17th January 2011, 12:58
Hello!
I want to transmit data to a SQLite database but this is done record
be record and takes much to long.
So I decided to use transaction(). But it is still working record by record,
so something must be wrong.
Can you tell me what is wrong?
Kind regards,
HomeR
This is the code:
QSqlDatabase dbSQL = QSqlDatabase::database();
dbSQL.transaction();
populateSQL(RemoteName,Purpose,DateString,value,cu rrQString);
dbSQL.commit();
int Banking::populateSQL(QString RemoteName,QString Purpose,QString Date,double Value ,QString Currency)
{
QSqlQuery query;
query.prepare(
"INSERT INTO onlinebankingdata ("
"RemoteName,"
"Purpose,"
"Date,"
"Value,"
"Currency)"
"VALUES ("
":RemoteName,"
":Purpose,"
":Date,"
":Value,"
":Currency)");
query.bindValue(":RemoteName", RemoteName);
query.bindValue(":Purpose", Purpose);
query.bindValue(":Date", Date);
query.bindValue(":Value", Value );
query.bindValue(":Currency", Currency);
bool test = query.exec();
if (!test)
{
QMessageBox::warning(0, QObject::tr("Database Error"),query.lastError().text());
}
return 0;
}
I want to transmit data to a SQLite database but this is done record
be record and takes much to long.
So I decided to use transaction(). But it is still working record by record,
so something must be wrong.
Can you tell me what is wrong?
Kind regards,
HomeR
This is the code:
QSqlDatabase dbSQL = QSqlDatabase::database();
dbSQL.transaction();
populateSQL(RemoteName,Purpose,DateString,value,cu rrQString);
dbSQL.commit();
int Banking::populateSQL(QString RemoteName,QString Purpose,QString Date,double Value ,QString Currency)
{
QSqlQuery query;
query.prepare(
"INSERT INTO onlinebankingdata ("
"RemoteName,"
"Purpose,"
"Date,"
"Value,"
"Currency)"
"VALUES ("
":RemoteName,"
":Purpose,"
":Date,"
":Value,"
":Currency)");
query.bindValue(":RemoteName", RemoteName);
query.bindValue(":Purpose", Purpose);
query.bindValue(":Date", Date);
query.bindValue(":Value", Value );
query.bindValue(":Currency", Currency);
bool test = query.exec();
if (!test)
{
QMessageBox::warning(0, QObject::tr("Database Error"),query.lastError().text());
}
return 0;
}