<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-mailStijl17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>At the end of some database maintenance where I drop several tables I want to Vacuum the SQLite database.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I use the code below and this works fine, however when I close the program I get the error:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>“Project project1 raised exception class ‘EDatabaseError’ with message:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Cannot rollback – no transaction is active.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US>Question: how can I Vacuum the database and close the program without errors?<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>The code (which gives no error when run):<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>procedure TForm1.VacuumButtonClick(Sender: TObject);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>begin<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SQLite3Connection.DatabaseName:='A.db';<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SQLTransaction1.Database:=SQLite3Connection;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SQLite3Connection.Open;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> // Statement below must be issued, otherwise I get error “cannot VACUUM from within a transaction”<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SQLite3Connection.ExecuteDirect('End Transaction'); // End the transaction started by SQLdb<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SQLite3Connection.ExecuteDirect('Vacuum');<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>end;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Exit procedure which give the error message.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>procedure TForm1.ExitMenuItemClick(Sender: TObject);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>begin<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Application.terminate;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>end;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><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”.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I run on Windows 7 32 bits and use Lazarus 1.0.12 and FPC 2.6.2<o:p></o:p></span></p></div></body></html>