Search code examples
androidsqlitedelphifiredac

Delphi Rio 10.3.2 Android FireDac SQLITE unable to open query - same code worked with Delphi Tokyo with same android device


Here is the very simple code that worked perfectly when compiled with Delphi Tokyo:

procedure TfData.DataSend(Memo : TMemo);
var SelectQuery : string;
begin
    // Query simplified, more fields are retreived in original code, but same problem with simple query
    SelectQuery := 'SELECT NUM as "NUM::TEXT" FROM TRACE WHERE DT_SENT is null ORDER BY DT_TRACE';
    YsDbQuerySelect.SQL.Clear;
    YsDbQuerySelect.SQL.Add(SelectQuery);
    YsDbQuerySelect.Prepare;
    try
      YsDbQuerySelect.Open;
      if YsDbQuerySelect.RecordCount > 0 then begin // I get 6 records here
        YsDbQuerySelect.First; // ********** Exception !

        while not YsDbQuerySelect.eof do begin    
         // making a file... code removed, not relevant          
          YsDbQuerySelect.Next;
        end;
        YsDbQuerySelect.Close;
      end
      else begin
        YsDbQuerySelect.Close;
        MesInfo('No data to send');
      end;
    except
      on e : exception do begin
        // Exception displays the annoying error
        MesError(e.Message + ' SLQ : ' + SelectQuery);
      end;
    end;
end;

The same simple code running on the same real android device (Zebra TC25) does not work anymore when compiled with Tokyo 10.3.2. The "RecordCount" method returns 6, however, the "First" method trigger an exception : something like "Cannot perform this operation on a closed dataset", the original message is in french : "Impossible d'effecteur cette opération sur un ensemble de données fermé"

I can't understand how "RecordCount" can return something while "First" triggers this exception. And there is indeed 6 record in database. I also deleted then recreated them. Same error. I tried to play with some options (fetch options and so on) but nothing is working. It's really annoying.

Note also that other operations work properly on the same SQLite database. The device is able to add and delete records using TDFCommand and to display them using TDataSource. Only TDFQuery encounters the error.


Solution

  • I deleted the TDFQuery component then I dropped a new one. It's a bit weird but it's working. I think there nothing to do with Delphi Rio but but with corrupted file ?