How to get the Identity Value from ClientDataSet:
Posted: 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
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