I use DataSnap delphi 2010.
UniQuery Component DMLRefresh Can fetch autoinc value,
but I cannot use it with datasnap.
I use Follow Code.
procedure TForm.dspDataAfterUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind);
begin
if UpdateKind = ukInsert then
quData.Fields[0].NewValue := GetLastID;
end;
GetLastID function is fetch autoinc value.
the code works grate with DBExpress. But not UniDac.
DataSnap + UniDac + AutoInc
-
AndreyZ
To solve this problem, it's needed to set the following options:In this case UniDAC will generate the SQL code, and the identity field value will be set automatically to the TUniQuery component. To update the identity field value in the TClientDataSet, component it's needed to use the following code:
Code: Select all
TDataSetProvider.ResolveToDataSet := True;
TUniQuery.RequiredFields := False;
TUniQuery.SetFieldsReadOnly := False;Code: Select all
procedure TForm1.DataSetProvider1AfterUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind);
begin
if UpdateKind = ukInsert then
DeltaDS.Fields[0].NewValue := UniQuery1.Fields[0].AsInteger;
end;