Access violation when calling Free on TIBCQuery.
Posted: Mon 10 Oct 2011 07:21
Hi,
I'm receiving an Access Violation error when calling Free on a TIBCQuery created in code.
Example code below from Sample form. Just placed a TIBCConnection component and setup database connection string. Then added button and attach it to OnClick event handler below.
I'm receiving an Access Violation error when calling Free on a TIBCQuery created in code.
Example code below from Sample form. Just placed a TIBCConnection component and setup database connection string. Then added button and attach it to OnClick event handler below.
Code: Select all
function TForm1.NewQuery(ANewTransaction: Boolean): TIBCQuery;
begin
Result := TIBCQuery.Create(Self);
Result.Connection := IBCConnection1;
if ANewTransaction then
begin
Result.Transaction := TIBCTransaction.Create(Result);
Result.UpdateTransaction := TIBCTransaction.Create(Result);
IBCConnection1.AddTransaction(Result.Transaction);
IBCConnection1.AddTransaction(Result.UpdateTransaction);
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
query: TIBCQuery;
begin
query := NewQuery(True);
try
query.SQL.Text := 'SELECT * FROM CUSTOMER';
query.Open;
// Do something here
finally
query.Close;
query.Free; // <- Access Violation here.
end;
end;