FDQuery append gives error "no such table"

Viewed 1947

In Delphi 10.1 I made a small program to learn about FireDAC and SQlite.

I have FDConnection, FDQuery (with SQL= SELECT * FROM Sætning) and DataSource + DBGrid. The DBGrid shows the (empty) table Sætning. I want to put data into my table from a listbox containg a CSV.

This is my code: (fdwSætning = an FDQuery)

procedure TMainForm.bCSV_SQLite_SætningClick(Sender: TObject);
var
  loop : integer;
  nr, lang, tekst : string;
begin
  { Read CSV file into Listbox }
  Listbox1.Items.LoadFromFile('GMS_Saetninger.txt');
  { Put the values from the CSV into the fields in each record }
  for loop:= 0 to Listbox1.Items.Count-1 do begin
    fdqSætning.Edit;
    nr:= copy(Listbox1.Items[loop],1,4);
    lang:= copy(Listbox1.Items[loop],5,2);
    tekst:= copy(Listbox1.Items[loop],8, length(Listbox1.Items[loop]));
    fdqSætning.Append;
    fdqSætning.FieldByName('SAETNING_ID').AsString:= nr;
    fdqSætning.FieldByName('LANGUAGE').AsString:= lang;
    fdqSætning.FieldByName('SENTENCE').AsString:= tekst;
    fdqSætning.Post;
  end;
end; 

When I run this code I get the error message

[FireDAC][phys][SQLite]ERROR:no such table: Sætning
1 Answers
Related