<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 13px;" lang="x-unicode">Hi,
<br>
<br>
I am using Lazarus 2.0.8, package SQLdb, under Win 10 (64). The
following procedure raises an exception with message
"TSQLite3Connection: Safety level may not be changed inside a
transaction". This is strange, since I think there is no active
transition in the moment when the exeption is raised.
<br>
<br>
Why this exception? How to fix? Is it maybe a bug in Lazarus 2.0.8
or in SQLdb?
<br>
<br>
Code:
<br>
<br>
procedure TForm1.TestButtonClick(Sender: TObject);
<br>
var XConnection: TSQLite3Connection;
<br>
XTransaction: TSQLTransaction;
<br>
XDatasource: TDataSource;
<br>
XQuery: TSQLQuery;
<br>
begin
<br>
XConnection:= TSQLite3Connection.Create(Form1);
<br>
XTransaction:= TSQLTransaction.Create(Form1);
<br>
XDatasource:= TDataSource.Create(Form1);
<br>
XQuery:= TSQLQuery.Create(Form1);
<br>
XQuery.DataBase:= XConnection;
<br>
XQuery.Transaction:= XTransaction;
<br>
XDatasource.DataSet:= XQuery;
<br>
XTransaction.DataBase:= XConnection;
<br>
XConnection.Transaction:= XTransaction;
<br>
XConnection.DatabaseName:= ExtractFilePath (Application.ExeName)
+ 'D.sqlite';
<br>
XQuery.SQL.Text:= 'PRAGMA synchronous=OFF';
<br>
try
<br>
XQuery.ExecSQL;
<br>
XTransaction.Commit;
<br>
except
<br>
on e: Exception do
<br>
ShowMessage ('Exception "' + e.Message + '"')
<br>
end;
<br>
XQuery.Free;
<br>
XDatasource.Free;
<br>
XTransaction.Free;
<br>
XConnection.Free;
<br>
end;
<br>
<br>
Regards -- Joe
<br>
</div>
</body>
</html>