<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>As the error message indicates, do:<BR><br>    SQLite3Connection.ExecuteDirect('Begin Transaction');    <BR> <BR>after the vacuum and you should be fine. Works for me.     <br> <BR><div><hr id="stopSpelling">From: mulcamd@hotmail.com<br>To: lazarus@lists.lazarus.freepascal.org<br>Date: Mon, 25 Nov 2013 09:31:24 +0100<br>Subject: [Lazarus] SQLite Vacuum & Error Cannot rollback - no transaction is    active<br><br><style><!--
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass div.ecxMsoNormal {
font-size:11.0pt;
font-family:"Calibri","sans-serif";
}

.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink {
color:blue;
text-decoration:underline;
}

.ExternalClass span.ecxMsoHyperlinkFollowed {
color:purple;
text-decoration:underline;
}

.ExternalClass span.ecxE-mailStijl17 {
font-family:"Calibri","sans-serif";
color:windowtext;
}

.ExternalClass .ecxMsoChpDefault {
font-family:"Calibri","sans-serif";
}

.ExternalClass div.ecxWordSection1 {
}

--></style><div class="ecxWordSection1"><p class="ecxMsoNormal"><span lang="EN-US">At the end of some database maintenance where I drop several tables I want to Vacuum the SQLite database.</span></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><span lang="EN-US">I use the code below and this works fine, however when I close the program I get the error:</span></p><p class="ecxMsoNormal"><span lang="EN-US">“Project project1 raised exception class ‘EDatabaseError’ with message:</span></p><p class="ecxMsoNormal"><span lang="EN-US">Cannot rollback – no transaction is active.</span></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><b><span lang="EN-US">Question: how can I Vacuum the database and close the program without errors?</span></b></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><span lang="EN-US">The code (which gives no error when run):</span></p><p class="ecxMsoNormal"><span lang="EN-US">procedure TForm1.VacuumButtonClick(Sender: TObject);</span></p><p class="ecxMsoNormal"><span lang="EN-US">begin</span></p><p class="ecxMsoNormal"><span lang="EN-US">                SQLite3Connection.DatabaseName:='A.db';</span></p><p class="ecxMsoNormal"><span lang="EN-US">                SQLTransaction1.Database:=SQLite3Connection;</span></p><p class="ecxMsoNormal"><span lang="EN-US">                SQLite3Connection.Open;</span></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><span lang="EN-US">                // Statement below must be issued, otherwise I get error “cannot VACUUM from within a transaction”</span></p><p class="ecxMsoNormal"><span lang="EN-US">                SQLite3Connection.ExecuteDirect('End Transaction');  // End the transaction started by SQLdb</span></p><p class="ecxMsoNormal"><span lang="EN-US">                SQLite3Connection.ExecuteDirect('Vacuum');</span></p><p class="ecxMsoNormal"><span lang="EN-US">end;</span></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><span lang="EN-US">Exit procedure which give the error message.</span></p><p class="ecxMsoNormal"><span lang="EN-US">procedure TForm1.ExitMenuItemClick(Sender: TObject);</span></p><p class="ecxMsoNormal"><span lang="EN-US">begin</span></p><p class="ecxMsoNormal"><span lang="EN-US">     Application.terminate;</span></p><p class="ecxMsoNormal"><span lang="EN-US">end;</span></p><p class="ecxMsoNormal"><span lang="EN-US"> </span></p><p class="ecxMsoNormal"><span lang="EN-US">BTW, when hitting the “break” button the cursor jumps to line 4828 “  inherited Destroy;” within the  “destructor TControl.Destroy;” in “control.inc”.</span></p><p class="ecxMsoNormal"><span lang="EN-US">I run on Windows 7 32 bits and use Lazarus 1.0.12 and FPC 2.6.2</span></p></div><br>--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</div>                                          </div></body>
</html>