How to get the Identity Value from ClientDataSet:

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Balaji
Posts: 20
Joined: Thu 05 Oct 2006 04:45

How to get the Identity Value from ClientDataSet:

Post by Balaji » Tue 12 Dec 2006 10:06

Hai,

I have TmSquery(Query1), TProvider (Provider1), TClienDataSet (ClientDataSet1) and a TDataSource components on the form.Query1 is attached to the Provider1 which is inturn attached to the ClientDataset1. This ClientdataSet1 is attached as the dataset to the DataSource component.
I am doing a normal insert operation into a table having Identity column using the ClientDataSet1 component.
I am doing the following piece of code:

ClientDataSet1.Insert;
ClientDataSet1.Fieldbyname('').AsInteger := 5;
ClientDataSet1.post;

Now, the table in which i am posting a record is having Identity Column. Now i want to have the identity Value that got generated so that i can pass it for inserting data into child tables. How to obtain the Identity Column value here ?

Note: I have already looked into some Identity Column queries that were posted in the group and did some things like, setting the autogenrateValue property to arAutoinc, setting the ReturnParams Option to TRUE etc..
But i was unable to write "Set :Columnname = SCOPE_Identity" beacuse i dont have any insert statement at all as i am using ClientDataSet.


Thanks in Advance

Regards
Balajee

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Tue 12 Dec 2006 15:29

This is restriction of using TClientDataSet component, not SDAC.
In your case Midas generates INSERT statement instead of SDAC SQL Generator.

Balaji
Posts: 20
Joined: Thu 05 Oct 2006 04:45

Post by Balaji » Wed 13 Dec 2006 07:03

Thanks for the reply.
I do know that it is not a restriction of SDAC...

My intention of posting this here is for an alternate solution so that i can get problem solved.
Is there any possible way to obtain Identity value in my case ?? if so please let me know...
I am working on a Migration project and i cannot completely replace the existing components as it is not part of our design..
so if u can provide me any alternative way of obtaining Identity Value it will be of great help to me..

Thanks in Advance...
Balajee

Post Reply