Page 1 of 1

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

Posted: Thu 16 Dec 2021 14:29
by RonBrisola
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.

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

Posted: Tue 08 Feb 2022 15:48
by Stellar
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

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

Posted: Mon 14 Feb 2022 04:42
by marcyhealy
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

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

Posted: Thu 10 Mar 2022 08:27
by Stellar
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