DataSnap + UniDac + AutoInc

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wbjsoft
Posts: 24
Joined: Tue 08 Aug 2006 00:38

DataSnap + UniDac + AutoInc

Post by wbjsoft » Wed 23 Mar 2011 13:48

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 23 Mar 2011 15:48

Hello,

Please specify the following information:
- the exact version of UniDAC;
- the name of your database.
Also please send a complete small sample to alexp*devart*com to demonstrate the problem.

wbjsoft
Posts: 24
Joined: Tue 08 Aug 2006 00:38

Post by wbjsoft » Wed 23 Mar 2011 18:26

I sent you sample program.

It works SQLite well.

But not work SQL Server.

I use unidac to build multi DB - SQLite,MySQL,SQL Server,Oracle.Etc.

Check the sample program and please answer me ASAP.

Thank you.

AndreyZ

Post by AndreyZ » Thu 24 Mar 2011 11:20

We have answered you by e-mail.

TinTin
Posts: 46
Joined: Sat 30 May 2009 14:09

Post by TinTin » Fri 25 Mar 2011 01:33

AndreyZ wrote:We have answered you by e-mail.
May I know the answer?

AndreyZ

Post by AndreyZ » Fri 25 Mar 2011 09:45

To solve this problem, it's needed to set the following options:

Code: Select all

TDataSetProvider.ResolveToDataSet := True;
TUniQuery.RequiredFields := False;
TUniQuery.SetFieldsReadOnly := False;
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

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;

Post Reply