0

I have a memory ClientDataset (provider is not specified) with the connected DBGrid. I need to change some records without DBGrid scrolling:

with ClientDataset do
begin
  DisableControls;
  try
    // changing some records
    // and getting back
  finally
    Refresh; // missing data provider error
    RefreshRecord; // missing data provider error
    EnableControls;
  end;
end;

Without Refresh DBGrid shows old data, without DisableControls the DBGrid is scrolling back and forth, Refresh causes error "missing data provider". Is there a way to properly organize it?

Molochnik
  • 704
  • 5
  • 23
  • 1
    Right now your question doesn't make any sense. The point of `Refresh` is to retrieve update data from the database (or other provider). You say you're using a ***memory*** Client Dataset; which is typically something you do when you don't have a table/query/provider to populate the data in the first place. How did you load the data in the first place if not via a provider? _You should "refresh" your data via an appropriately similar mechanism._ – Disillusioned Nov 07 '17 at 02:16
  • I can't reproduce this with a quick test app which uses `CreateFieldDefs` to create the CDS, `AppendRecord` to add a few records in the `FormCreate`, and then in a button's OnClick handler does `DisableControls; Last; Edit; { Change data } MoveBy(-3); { Change some data } Post; First; EnableControls;`. I click the button, and the data changes without doing anything more. This means you have some other issue we can't see. – Ken White Nov 07 '17 at 02:22
  • your code is not clear to understand, ClientDataSet without a provider will rise error when you are adding fields!!!! please provide more details. – Aqil Nov 10 '17 at 23:15

0 Answers0