From 6677a69a4254b73a91571808bd569337ecd40e39 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 5 Dec 2018 10:05:26 +0100 Subject: Fix creating new series Well, there is something fishy going on. I have no idea why that commit is needed there, but during debugging I also noticed that on the final commit() the database complains that there's no transaction in progress. Well, this works, but I don't know how to debug this further :( --- newmoviewizard.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'newmoviewizard.cpp') diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp index 790f2a0..8cd9936 100644 --- a/newmoviewizard.cpp +++ b/newmoviewizard.cpp @@ -55,11 +55,12 @@ void NewMovieWizard::accept(){ insertSeriesQ.prepare("INSERT INTO series (tseries_name) VALUES(:name)"); insertSeriesQ.bindValue(":name", seriesName); if(insertSeriesQ.exec()){ - seriesIdQ.bindValue(":value", seriesName); - seriesIdQ.exec(); - while(seriesIdQ.next()){ - seriesId = seriesIdQ.value(0).toInt(); + QSqlQuery curval("SELECT currval('series_iseries_id__seq')", db); + while(curval.next()){ + seriesId = curval.value(0).toInt(); } + db.commit(); + db.transaction(); }else{ QMessageBox::critical(this, tr("Error"), tr("Failed to create series!")); db.rollback(); -- cgit v1.2.3-70-g09d2