Pascal D
Pascal D

Reputation: 258

Delphi: ResolveToDataset issue

I am using a TClientDataset with the following options for the provider:

ResolveToDataSet = True
Options = [poPropogateChanges, poUseQuoteChar]
UpdateMode = upWhereKeyOnly
AfterUpdateRecord = DataSetProvider1AfterUpdateRecord

The provider is connected to a TIBCQuery which manages the generator for the NO_INVOICE key.

On AfterUpdateRecord the following code is done (as found in many places in groups to really propagate the key change when posting to the database)

DeltaDS.FieldByName(ClientDataSet1NO_INVOICE.FieldName).NewValue 
  := SourceDS.FieldByName(ClientDataSet1NO_INVOICE.FieldName).NewValue

The following code is then used to add a record:

  ClientDataSet1.Params[0].AsInteger := -1;
  ClientDataSet1.Open;
  ClientDataSet1.Edit;
  ClientDataSet1NO_INVOICE.AsInteger := -1;
  ClientDataSet1NO_STORE.AsInteger := 1;
  ClientDataSet1.Post;
  ClientDataSet1.ApplyUpdates(-1);

If I call ClientDataSet1.Refresh after the ApplyUpdate, the underlying TIBCQuery is reopened with the original param of -1 and not with the new key—even if the ClientDataSet1NO_INVOICE.AsInteger shows up the new value assigned after merging records.

The use of Refresh here is only to simplify this example. The problems happens when we:

Did I miss something with the usage of the ResolveToDataset option, or should I explicitly reopen the query with the new param?

I never had this problem before when using ResolveToDataset = False on other projects.

Upvotes: 3

Views: 1239

Answers (0)

Related Questions