Search code examples
delphibde

Does TQuery.Unprepare close the query result in Delphi?


I wonder whether in Delphi calling

Query1.Unprepare;

implicitly closes Query1, if it was previously active. Such that e.g. calling Next on it will fail.

You might say, just go ahead and try but I did on a 64-bit Windows 7 system and had all sort of problems with it until finally my BDE Administrator seems to be completely broken. So I decided to just ask this questions before I start to find out, how I can get BDE running on my system ;-)


Solution

  • You can not use Prepare/Unprepare on an open dataset. you need to close it first.

    unit DBTables;
    ...
    procedure TQuery.SetPrepared(Value: Boolean);
    begin
      if Handle <> nil then DatabaseError(SDataSetOpen, Self);
      ...
      // SDataSetOpen = 'Cannot perform this operation on an open dataset';