Talk:Lazarus Tdbf Tutorial
From Free Pascal wiki
Jump to navigationJump to searchThe following code
var
MyDbf: TDbf;
begin
try
MyDbf := TDbf.Create(nil);
{ use relative path to "data" directory }
// etc ..
MyDbf.Close;
finally
MyDbf.Free;
end;
end;
should have the Create statement outsite of the try .. finally construct. Because when something goes wrong with the creation what has been created will be automatically freed. (At least this way it is in Delphi)
So I would advise to change to code to
var
MyDbf: TDbf;
begin
MyDbf := TDbf.Create(nil);
try
//etc.