Update bindsource and listview

回眸只為那壹抹淺笑 提交于 2019-12-24 07:16:33

问题


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:


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;


来源:https://stackoverflow.com/questions/19171302/update-bindsource-and-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!