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

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Cristiano
Posts: 11
Joined: Mon 08 Aug 2011 00:16

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

Post by Cristiano » Thu 25 Aug 2011 23:03

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

AndreyZ

Post by AndreyZ » Mon 29 Aug 2011 14:40

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.

Post Reply