Get new Identity Inserted in ClientDataSet (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
RonBrisola
Posts: 14
Joined: Wed 14 Nov 2012 12:59

Get new Identity Inserted in ClientDataSet (Delphi + SQL Server with Devart)

Post by RonBrisola » Thu 16 Dec 2021 14:29

Hello.

I'm inserting a new record in a table with an identity column.

It's possible to retrieve the value generated on this new record after the post is finished?

Thanks,
Ronaldo.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: Get new Identity Inserted in ClientDataSet (Delphi + SQL Server with Devart)

Post by Stellar » Tue 08 Feb 2022 15:48

Hi Ronaldo!

Thanks for contacting us.

TDataSetProvider independently generates an SQL statement for adding a record to the database.
We cannot influence which SQL statement will be generated by TDataSetProvider.
Not the best option, but to update the records you can reopen the dataset, for example:

Code: Select all

ClientDataSet1.Close; 
ClientDataSet1.Open; 
You can fully work with SQL Server using Devart dbExpress Driver for SQL Server. But we recommend you to use our other SDAC components: https://www.devart.com/sdac/ and UniDAC: devart.com/unidac. They are better in performance and functionality than using dbExpress technology, and also allow you to get the value of the identifier when adding a record.

Best regards,
Sergey

marcyhealy
Posts: 1
Joined: Mon 14 Feb 2022 04:29

Re: Get new Identity Inserted in ClientDataSet (Delphi + SQL Server with Devart)

Post by marcyhealy » Mon 14 Feb 2022 04:42

Stellar wrote: Tue 08 Feb 2022 15:48 Hi Ronaldo!

Thanks for contacting us.

TDataSetProvider independently generates an SQL statement for adding a record to the database.
We cannot influence which SQL statement will be generated by TDataSetProvider.
Not the best option, but to update the records you can reopen the dataset, for example:

Code: Select all

ClientDataSet1.Close; 
ClientDataSet1.Open; 
You can fully work with SQL Server using Devart dbExpress Driver for SQL Server. But we recommend you to use our other SDAC components: https://www.devart.com/sdac/ and UniDAC: devart.com/unidac. They are better in performance and functionality than using dbExpress technology, and also allow you to get the value of the identifier when adding a record.

Best regards,
Sergey
That is very helpful! thank you

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: Get new Identity Inserted in ClientDataSet (Delphi + SQL Server with Devart)

Post by Stellar » Thu 10 Mar 2022 08:27

Hi Ronaldo!

Thank you for your reply! I was happy to assist you!
In case you have any further questions about our products, please feel free to contact us any time!

Best regards,
Sergey

Post Reply