Page 1 of 1

Get Id Inserted in Table (Delphi + SQL Server with Devart)

Posted: Thu 25 Aug 2011 23:03
by Cristiano
Hi,
I'm using ClientDataSet + TDataSetProvider to insert record in a single table.
In the event AfterUpdateRecord of the TDataSetProvider i'm making a database connection (using the same TSQLConnection of TSQLDataSet connected) to get the SCOPE_IDENTITY the inserted row, but it is always returning 0 (or null) ..
Any idea about this problem?
There may be some bug with the driver?

Tks for attention

Posted: Mon 29 Aug 2011 14:40
by AndreyZ
Hello,

To obtain the new value of an autoincrement field, you have to refresh a dataset (close and open TClientDataSet). This is a specifity of dbExpress work with autoincrement fields.