1

I am working on a Delphi XE5 Firemonkey Mobil app.

I use FireDac for connection.

Just trying to do a simple query insert into sQlite database and update the listview with the inserted info.

  procedure TTabbedwithNavigationForm.Button4Click(Sender: TObject);
   begin

   DataModule1.qSelectCustomers.SQL.Text := 'insert into Invoice (Name) values(:newName)';
   DataModule1.qSelectCustomers.ParamByName('newName').AsString := 'test';
   DataModule1.qSelectCustomers.ExecSQL;
   BindSourceDB1.DataSet.Refresh;
   ////LinkFillControlToField1.BindList.FillList;
  end;

My problem is i am getting error. error:= TFDQuery : Can not perform this operation on a closed dataset. I have tried opening the dats set but no go. Why will this not work ?

1
  • Why are you using the SELECT query to INSERT? Use a separate query for inserting, and one for deleting. See the Sample in the FireMonkey Mobile Code Snippets folder (it's the FireDACSQLLite demo). Commented Oct 4, 2013 at 1:10

1 Answer 1

3

You can insert a record into a dataset with a select query like this:

DataModule1.qSelectCustomers.SQL.Text := 'SELECT * FROM Invoice';
DataModuel1.qSelectCustomers.Active := True;
DataModule1.qSelectCustomers.Append;
DataModule1.qSelectCustomers.FieldByName('Name').Value := 'test';
DataModule1.qSelectCustomers.Post;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.